> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS

> Connect an AWS account for resource autodiscovery and S3 log delivery

The AWS Cloud Account uses a cross-account IAM role to access your AWS infrastructure for resource autodiscovery and log forwarding.

## What Formal Discovers

> [accordion] RDS Autodiscovery
>
> Automatically discover PostgreSQL, MySQL, and MongoDB RDS instances, and
> Aurora and DocumentDB clusters, and add them as Formal resources.

> [accordion] Redshift Autodiscovery
>
> Discover Redshift clusters and data warehouses.

> [accordion] EKS Autodiscovery
>
> Discover EKS clusters for Kubernetes access control.

> [accordion] EC2 Autodiscovery
>
> Discover EC2 instances for SSH access.

> [accordion] ECS Autodiscovery
>
> Discover ECS clusters, services, and containers for SSH access via the
> Formal Endpoint.

> [accordion] S3 Bucket Autodiscovery
>
> Discover S3 buckets for access via the Formal Endpoint.

> [accordion] S3 Log Forwarding
>
> Write logs to S3 buckets through a
> [Log Forwarding](https://docs.formal.ai/docs/guides/integrations/log.md#aws-s3).

## Architecture

Formal uses AWS's [Cross-Account IAM Role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html) architecture:

1. **CloudFormation Stack**: deploys an IAM role in your AWS account
2. **IAM Role**: grants Formal specific, scoped permissions
3. **External ID**: a unique identifier that prevents unauthorized access
4. **Role Chaining**: Formal uses IAM User → IAM Role → your IAM Role for added security

## Supported Regions

The CloudFormation stack can be deployed in:

* `us-east-1`, `us-east-2`, `us-west-1`, `us-west-2`
* `eu-central-1`, `eu-west-1`, `eu-west-2`, `eu-west-3`

**The IAM role provides global access**, allowing Formal to discover resources across all AWS regions.

## Setup

> [tab] Control Plane
>
> **1. Navigate to Cloud Accounts**
>
> Go to [Cloud Accounts](https://app.formal.ai/cloud-accounts)
>
> **2. Create Integration**
>
> Click **Create Integration**
>
> **3. Select AWS**
>
> Choose AWS as your cloud provider
>
> **4. Deploy CloudFormation**
>
> Click the provided link to deploy the CloudFormation template in your AWS account.
>
> The template creates an IAM role with the necessary permissions.
>
> **5. Configure Permissions**
>
> Enable the features you need:
>
> * RDS Autodiscovery
> * Redshift Autodiscovery
> * EKS Autodiscovery
> * EC2 Autodiscovery
> * ECS Autodiscovery
> * S3 Autodiscovery
> * S3 Write Access (for log forwarding)
>
> **6. Complete Setup**
>
> Once CloudFormation deployment completes, your AWS integration is active.

> [tab] Terraform
>
> ```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> # 1. Create S3 bucket for logs (optional)
> resource "aws_s3_bucket" "formal_logs" {
>   bucket = "formal-connector-logs"
> }
>
> # 2. Create Formal Cloud Integration
> resource "formal_integration_cloud" "aws" {
>   name         = "production-aws"
>   cloud_region = "us-east-1"
>
>   aws {
>     template_version              = "1.6.0"  # Pin to specific version
>     enable_rds_autodiscovery      = true
>     enable_redshift_autodiscovery = true
>     enable_eks_autodiscovery      = true
>     enable_ec2_autodiscovery      = true
>     enable_ecs_autodiscovery      = true
>     enable_s3_autodiscovery       = true
>     allow_s3_access               = true
>     s3_bucket_arn                 = "${aws_s3_bucket.formal_logs.arn}/*"
>   }
> }
>
> # 3. Deploy CloudFormation Stack
> resource "aws_cloudformation_stack" "formal" {
>   name          = formal_integration_cloud.aws.aws_formal_stack_name
>   template_body = formal_integration_cloud.aws.aws_template_body
>
>   parameters = {
>     FormalIntegrationId         = formal_integration_cloud.aws.id
>     FormalIAMRoleId             = formal_integration_cloud.aws.aws_formal_iam_role
>     FormalSNSTopicARN           = formal_integration_cloud.aws.aws_formal_pingback_arn
>     EnableRDSAutodiscovery      = formal_integration_cloud.aws.aws_enable_rds_autodiscovery
>     EnableRedshiftAutodiscovery = formal_integration_cloud.aws.aws_enable_redshift_autodiscovery
>     EnableEKSAutodiscovery      = formal_integration_cloud.aws.aws_enable_eks_autodiscovery
>     EnableEC2Autodiscovery      = formal_integration_cloud.aws.aws_enable_ec2_autodiscovery
>     EnableECSAutodiscovery      = formal_integration_cloud.aws.aws_enable_ecs_autodiscovery
>     EnableS3Autodiscovery       = formal_integration_cloud.aws.aws_enable_s3_autodiscovery
>     AllowS3Access               = formal_integration_cloud.aws.aws_allow_s3_access
>     S3BucketARN                 = formal_integration_cloud.aws.aws_s3_bucket_arn
>   }
>
>   capabilities = ["CAPABILITY_NAMED_IAM"]
> }
> ```

> [tab] Terraform (without CloudFormation)
>
> > [!NOTE]
> >
> > If not using CloudFormation, the IAM role name needs to be pre-declared. This is because the role needs the Formal principal ARN for its trust policy, but the integration needs the role ARN to generate that principal. Since IAM role ARNs are predictable, you can pass the ARN before the role exists, allowing the below example to create both resources in a single apply.
>
> > [!NOTE]
> >
> > Set either `template_version` (CloudFormation path) or `aws_customer_role_arn` (manual IAM path). Terraform requires at least one.
>
> ```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
> locals {
>   formal_integration_role_name = "FormalIntegrationRole"
>   s3_log_forwarding_bucket_arn = "arn:aws:s3:::formal-logs-forwarder/*"
> }
>
> resource "formal_integration_cloud" "aws" {
>   name         = "production-aws"
>   cloud_region = "us-east-1"
>
>   aws {
>     aws_customer_role_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/${locals.formal_integration_role_name}"
>     enable_eks_autodiscovery = true
>     enable_ec2_autodiscovery = true
>     enable_ecs_autodiscovery = true
>     enable_rds_autodiscovery = true
>     enable_s3_autodiscovery = true
>     allow_s3_access = true
>     s3_bucket_arn = locals.s3_log_forwarding_bucket_arn
>   }
> }
>
> resource "aws_iam_role" "formal" {
>   name = locals.formal_integration_role_name
>
>   assume_role_policy = jsonencode({
>     Version = "2012-10-17"
>     Statement = [
>       {
>         Action = "sts:AssumeRole"
>         Effect = "Allow"
>         Principal = {
>           AWS = formal_integration_cloud.aws.aws_formal_iam_role
>         }
>         Condition = {
>           StringEquals = {
>             sts:ExternalId = formal_integration_cloud.aws.id
>           }
>         }
>       }
>     ]
>   })
>
>   inline_policy = {
>     name = "FormalIntegrationRolePolicy"
>     policy = jsonencode({
>       Version = "2012-10-17"
>       Statement = [
>         {
>           Effect = "Allow"
>           Action = [
>             "sts:GetCallerIdentity",
>             "eks:ListClusters",
>             "eks:DescribeCluster",
>             "ec2:DescribeInstances",
>             "ec2:DescribeRegions",
>             "ecs:ListClusters",
>             "ecs:DescribeClusters",
>             "ecs:ListTasks",
>             "ecs:DescribeTasks",
>             "ecs:ListServices",
>             "ecs:DescribeServices",
>             "rds:DescribeDBInstances",
>             "rds:DescribeDBClusters",
>             "s3:ListAllMyBuckets",
>             "s3:HeadBucket",
>           ]
>           Resource = ["*"]
>         },
>         {
>           Effect = "Allow"
>           Action = [
>             "s3:PutObject",
>           ]
>           Resource = [locals.s3_log_forwarding_bucket_arn]
>         }
>       ]
>     })
>   }
> }
> ```

## S3 Log Delivery

To forward logs to S3, the integration needs S3 write access. Enable it when creating the integration with two settings:

| Setting | Description |
| - | - |
| `allow_s3_access` | Grants Formal's IAM role `s3:PutObject` permission. |
| `s3_bucket_arn` | Objects Formal may write to. Use a `/*` suffix, e.g. `arn:aws:s3:::my-bucket/*`. |

Once access is granted, configure [Log Forwarding](https://docs.formal.ai/docs/guides/integrations/log.md#aws-s3) for the bucket to start forwarding logs.

## CloudFormation Parameters

| Parameter | Description | Default |
| - | - | - |
| `EnableRDSAutodiscovery` | Discover RDS instances and clusters (PostgreSQL, MySQL, MongoDB) | `false` |
| `EnableRedshiftAutodiscovery` | Discover Redshift clusters | `false` |
| `EnableEKSAutodiscovery` | Discover EKS clusters | `false` |
| `EnableEC2Autodiscovery` | Discover EC2 instances | `false` |
| `EnableECSAutodiscovery` | Discover ECS clusters and containers | `false` |
| `EnableS3Autodiscovery` | Discover S3 buckets | `false` |
| `AllowS3Access` | Allow log forwarding to S3 | `false` |
| `S3BucketARN` | S3 bucket ARN for logs (if `AllowS3Access` is true) | `""` |

## Versioning

The CloudFormation template is versioned for stability. `template_version` selects which template Formal returns in `aws_template_body` when you deploy the stack with `aws_cloudformation_stack`.

In Terraform, set **at least one** of:

* `template_version` — CloudFormation path (`"latest"` or a pinned semver)
* `aws_customer_role_arn` — manual IAM path (omit `template_version`; Formal does not generate a template)

The control plane API still defaults a missing `template_version` to `"latest"` when no customer role ARN is provided (for example, the Control Plane flow). Terraform requires an explicit choice so plans stay stable.

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
aws {
  template_version = "latest"
  # ...
}
```

**Benefits of version pinning:**

* Predictable IAM permissions
* Controlled feature adoption
* Easier compliance auditing
* Prevents unexpected changes

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
aws {
  template_version = "1.2.0"  # Pin when you need a fixed template
  # ...
}
```

See the [CloudFormation Changelog](https://docs.formal.ai/docs/changelog/cloudformation.md) for version history. The API rejects unknown versions at create time.

## Security

Formal implements multiple security layers:

1. **Role Chaining**: IAM User → IAM Role in Formal account → IAM Role in your account
2. **External ID**: a unique per-customer identifier that prevents cross-tenant access
3. **Least Privilege**: CloudFormation grants only required permissions
4. **Scoped Permissions**: enable only the features you need

Example: if you only enable RDS autodiscovery, the IAM role cannot access EKS, EC2, or S3.

## Discovered Resources

Once the integration is active, Formal scans your AWS account and creates matching Formal resources:

* RDS instance `prod-postgres-1` → Formal resource `prod-postgres-1`
* Aurora cluster `orders` → Formal resources `orders` and `orders-ro`
* EKS cluster `production-eks` → Formal resource `production-eks`
* EC2 instance `i-abc123` → Formal resource `ec2-i-abc123`

Discovery is continuous and resource tags sync to Formal. See [Resource Autodiscovery](https://docs.formal.ai/docs/guides/integrations/clouds/introduction.md#resource-autodiscovery) for how discovered resources behave and how to override them.

### RDS and Aurora Clusters

Formal discovers Aurora, DocumentDB, and Multi-AZ DB clusters with `rds:DescribeDBClusters`. Each cluster becomes two resources:

| Resource | Hostname | Use for |
| - | - | - |
| `<cluster>` | Cluster writer endpoint | Writes and failover |
| `<cluster>-ro` | Cluster reader endpoint | Read-only traffic |

Both resources carry the cluster's AWS tags. Formal no longer lists the cluster's member instances separately.

Template `1.6.0` adds `rds:DescribeDBClusters`. To enable cluster discovery on an existing integration, update the CloudFormation stack to `1.6.0`, or add `rds:DescribeDBClusters` to the IAM role. Until then, Formal keeps discovering member instances as before.

## Multiple Accounts

Create a separate integration for each AWS account to keep environments isolated:

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# Production account
resource "formal_integration_cloud" "aws_prod" {
  name         = "aws-production"
  cloud_region = "us-east-1"

  aws {
    template_version         = "1.2.0"
    enable_rds_autodiscovery = true
  }
}

# Staging account
resource "formal_integration_cloud" "aws_staging" {
  name         = "aws-staging"
  cloud_region = "us-west-2"

  aws {
    template_version         = "1.2.0"
    enable_rds_autodiscovery = true
  }
}
```

## Troubleshooting

> [accordion] CloudFormation deployment fails
>
> **Possible causes:**
>
> * Insufficient IAM permissions to create roles
> * Stack name conflict
> * Region not supported
>
> **Solution:**
>
> 1. Ensure the deploying user has IAM role creation permissions
> 2. Use the unique stack name provided by Formal
> 3. Deploy in a supported region

> [accordion] Resources not discovered
>
> **Possible causes:**
>
> * Autodiscovery not enabled for that resource type
> * Resources in an unsupported region
> * IAM permissions insufficient
>
> **Solution:**
>
> 1. Verify the autodiscovery toggle is enabled in the Control Plane
> 2. Check the resources exist in AWS
> 3. Review the CloudFormation IAM role permissions
> 4. Wait a few minutes for the initial scan

> [accordion] S3 log forwarding not working
>
> **Possible causes:**
>
> * S3 bucket ARN incorrect
> * IAM role lacks S3 permissions
> * Log integration not configured
>
> **Solution:**
>
> 1. Verify `s3_bucket_arn` matches the permissions you want to grant on objects (e.g., use a `/*` suffix for all files)
> 2. Ensure `allow_s3_access` is enabled
> 3. Configure [Log Forwarding](https://docs.formal.ai/docs/guides/integrations/log.md) for this cloud integration

## Next Steps

> [card] [Log Forwarding](https://docs.formal.ai/docs/guides/integrations/log.md)
>
> Forward logs to S3

> [card] [Add Resources](https://docs.formal.ai/docs/guides/core-concepts/resources/introduction.md)
>
> Manually configure discovered resources

> [card] [Terraform](https://docs.formal.ai/docs/guides/configuration/terraform.md)
>
> Manage integrations as code

> [card] [View Resources](https://app.formal.ai/resources)
>
> See all autodiscovered resources


## Related topics

- [AWS](https://docs.formal.ai/docs/guides/core-concepts/resources/aws.md)
- [AWS S3](https://docs.formal.ai/docs/guides/core-concepts/resources/s3.md)
- [SSH/AWS SSM](https://docs.formal.ai/docs/guides/core-concepts/resources/ssh.md)
- [Reach the Control Plane over AWS PrivateLink](https://docs.formal.ai/docs/guides/control-plane/private-link.md)
- [Log In to the Endpoint with OIDC](https://docs.formal.ai/docs/guides/client-apps/oidc.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.