# Non-human identities from AWS

Besides certificates and keys, the Amazon Web Services collector adds the IAM
roles and IAM users that software uses to your non-human identity inventory in
Mesh. It also shows who owns them and which workloads run as them.

This page covers what you see and what each part needs. The collector itself is
set up as described in [Amazon Web Services](./mesh-setup.md). In the connector
list it appears as **Crypto Cloud AWS**.

## What you see in Mesh

| In Mesh | What it shows | What it needs |
| --- | --- | --- |
| **Workload identities** list | IAM roles that an AWS service or an OIDC provider can assume | The **IAM permissions and usage** switch |
| **Service accounts** | IAM users with no console password and at least one active access key | The **IAM permissions and usage** switch and the credential report permissions below |
| **Owners** | The owners named in your resource tags | The **Owner tag keys** field |
| **Permission flow** | The EC2 instances, Lambda functions and ECS services that run as each role | The **Workload identities** switch and the read permissions below |

Roles used only for SAML or single sign-on, and AWS service-linked roles, are
not listed.

### Owners from tags

Mesh reads owners from the tags on each role and user. The **Owner tag keys**
field lists the tag keys to read. If you leave it empty, Mesh reads `Owner`,
then `owner`.

To give an owner a role, add `=ROLE` after the key. The role can be
`BUSINESS`, `TECHNICAL` or `SECURITY`. A key with no role gives an owner whose
role is unspecified.

```text
Owner,CostOwner=BUSINESS,OpsOwner=TECHNICAL
```

Each key found on a role or user becomes its own owner. If the tag value names
an IAM user or group in the same AWS account, Mesh links to it. Any other value,
such as an email address or a team name, is kept as written and shows as
unresolved.

### Deleted roles and users

Mesh marks a role or user deleted only after a collection that read your IAM
data in full, and that read counts as complete only when the credential report
was read. Without the credential report permissions below, roles that left AWS
stay in Mesh. AWS can reuse a credential report for up to four hours, so a
user you delete can still appear for that long.

### Workloads and the roles they run as

With the **Workload identities** switch on, Mesh links:

- each EC2 instance to the role of its instance profile;
- each Lambda function to its execution role;
- each ECS service to its task role.

The links appear in the **Permission flow** tab of the role.

![The Permission flow tab of an AWS role, showing the EC2 instance that runs as the role and the evidence that each end was collected](/img/connectors/crypto-aws/aws-nhi-02-permission-flow.png)

Mesh finds the role behind an instance profile from the IAM data it reads when
**IAM permissions and usage** is on, so the EC2 link needs no extra IAM
permission. It needs that read to have completed.

## Permissions to add

Grant these permissions to the IAM role that Mesh assumes when you set **Role to
use**. If you leave that field empty, grant them to the IAM user or role whose
access key Mesh uses. When Mesh assumes a role, the access-key user also needs
`sts:AssumeRole` on that role, as described in [Amazon Web
Services](./mesh-setup.md). The EC2, Lambda and ECS permissions are needed only
if you turn on the **Workload identities** switch, and they apply in every
Region the collector reads.

| Permission | Used for |
| --- | --- |
| `iam:GetAccountAuthorizationDetails` | IAM roles, users and their policies. Needed whenever **IAM permissions and usage** is on |
| `iam:GenerateServiceLastAccessedDetails`, `iam:GetServiceLastAccessedDetails` | When each role and user last used an AWS service. Needed whenever **IAM permissions and usage** is on |
| `ec2:DescribeInstances` | EC2 instances |
| `lambda:ListFunctions` | Lambda functions |
| `ecs:ListClusters`, `ecs:ListServices`, `ecs:DescribeServices`, `ecs:DescribeTaskDefinition` | ECS services and their task roles |
| `iam:GenerateCredentialReport`, `iam:GetCredentialReport` | Non-human IAM users. Without both, these users are not shown |

A permission you do not grant skips only its own part. The connector then shows
**Partial** and says what to allow. An explicit deny, a permissions boundary or
an organization service control policy can also block a permission.

## Turn the options on in Mesh

1. On the **Connectors** page, open the row menu of your Amazon Web Services
   connector and choose **Edit**.
2. On the **Collection** tab, turn on **IAM permissions and usage**.
3. To show which workloads run as each role, also turn on **Workload
   identities**. It is off by default.
4. To read owners, enter the tag keys in **Owner tag keys** on the **Advanced**
   tab.
5. Save the connector.

![The Collection tab of the Edit panel, showing the IAM permissions and usage and Workload identities switches](/img/connectors/crypto-aws/aws-nhi-01-collection-switches.png)

After the first collection, your roles and users appear under **Non-human
identities**.

## Troubleshooting

| Symptom | Likely cause | What to do |
| --- | --- | --- |
| No roles or users appear | **IAM permissions and usage** is off | Turn the switch on |
| No roles or users appear although the switch is on | A permission in **Permissions to add** is missing, most often `iam:GetAccountAuthorizationDetails`. The connector shows **Partial** | Grant it to the identity Mesh reads AWS as, and wait for the next collection |
| No **Permission flow** links | The **Workload identities** switch is off | Turn the switch on |
| No service accounts from IAM users | Mesh could not read the IAM credential report | Add `iam:GenerateCredentialReport` and `iam:GetCredentialReport` |
| The connector shows **Partial** | A permission is missing | Read the reason shown and add the permission |
| A role has no owner | No tag matches **Owner tag keys** | Add the tag in AWS, or add its key to the field |
| An owner shows as unresolved | The tag value is not an IAM user or group in the same account | Use an IAM user or group name, or accept the value as written |
| A workload has no **Permission flow** link | An EC2, Lambda or ECS permission is missing | Add it and wait for the next collection |
