> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/a/aws-ec2.md).

# AWS EC2

Amazon EC2 provides virtual servers. OctoXLabs lists the instances of every region the access key can reach. It can also collect security group rules and network ACL entries as policy assets.

## Use cases

* List the policy assets collected from EC2 (security group rules and network ACL entries).

```
Adapters = aws-ec2
```

* Find devices that AWS EC2 reports but your EDR does not cover.

```
Adapters = aws-ec2 AND NOT Adapters = falcon-crowdstrike
```

* Review devices that AWS EC2 has not seen recently.

```
Adapters = aws-ec2 AND NOT LastSeen last now-30d/d
```

* Check what one AWS EC2 connection collected.

```
Connections = YOUR_CONNECTION_NAME
```

## Before you begin

### Network

| Source              | Destination            | Port | Protocol |
| ------------------- | ---------------------- | ---- | -------- |
| OctoXLabs connector | EC2 regional endpoints | 443  | HTTPS    |

### Required permissions

| Scope or role                                                                       | Permission | Needed for                         |
| ----------------------------------------------------------------------------------- | ---------- | ---------------------------------- |
| ec2:DescribeRegions, ec2:DescribeInstances, ec2:DescribeImages                      | Read       | Regions, instances and image names |
| ec2:DescribeSecurityGroups, ec2:DescribeSecurityGroupRules, ec2:DescribeNetworkAcls | Read       | Only for the policy options        |

The policy permissions are included in the **AmazonEC2ReadOnlyAccess** managed policy. Without them the device inventory still works but no policy is collected. The exact permissions for the instance calls are inferred from the code. Not verified against vendor text.

## Create credentials in AWS EC2

Create an IAM user (or role) with the read-only permissions above, then create an access key for it. See [AWS access keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html). The secret is shown only once.

## Connection parameters

| Parameter                  | Required | Type    | Default | Description                                                                                                            |
| -------------------------- | -------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| Access Key ID              | Yes      | String  | None    | AWS Access Key ID.                                                                                                     |
| Secret Access Key          | Yes      | String  | None    | AWS Secret Access Key.                                                                                                 |
| Region                     | Yes      | String  | None    | A region used to start the scan, for example `eu-north-1`. The adapter then reads every region that this key can list. |
| Fetch Security Group Rules | No       | Boolean | False   | Collect security group rules as policy assets.                                                                         |
| Fetch Network ACL Rules    | No       | Boolean | False   | Collect network ACL entries as policy assets. Network ACLs can also deny traffic.                                      |
| Attach Policies to Devices | No       | Boolean | False   | Attach the security group and network ACL rules that govern each instance to its record.                               |

## Troubleshooting

| Error message                                                          | Cause                                                                  | Fix                                                                                                                                           |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| Status Code: `, followed by the URL, the method and the response body` | The API answered with a status other than the one the adapter expects. | Read the code and body. 401 or 403 usually points to wrong credentials or missing permissions. Check the address, port and Is Secure setting. |

## Change history
