# Connect AWS > How to give the panel access to your AWS account, through the CloudFormation link or an IAM key, and how to remove that access. To create servers, networks, databases, buckets and load balancers in your AWS account, the panel needs access to it. There are two ways: **via link** (recommended), which creates an IAM role in your account with one click in CloudFormation, or **with an access key** from an IAM user. Everything the panel creates stays in your account and is billed by AWS. ## Before you start - In the panel, you need the **Manage providers** permission. By default, only the team owner has it. - In AWS, sign in with a user that can create CloudFormation stacks and IAM resources (roles and policies). An account administrator works. - Pick the right account: if you serve clients, you can connect each client's AWS account. Each connection shows up as a separate provider. ## Which method to use | | Via link (recommended) | Access key | |---|---|---| | What the panel keeps | A role ARN and a connection identifier (ExternalId) | An IAM user's Access key ID and Secret access key | | Key that can leak | None | Yes: it's a permanent key | | Who can use the role | Only the platform's account, and only with this connection's ExternalId | Anyone who has the key | | Connection pooling (RDS Proxy) | Yes | No | | How to remove | Delete the stack in CloudFormation | Deactivate the key in IAM | ## Connect via link (recommended) The link opens the AWS console straight on the CloudFormation stack creation screen, with the template and parameters filled in. You just confirm, and the panel connects on its own when the stack finishes. 1. In the panel, open **Integrations → Cloud providers** and click **Connect AWS**. 2. Keep the **Via link (recommended)** tab selected. 3. Fill in the **Name** (for example, `AWS Produção`) and pick the **Default region**. 4. Click **Open AWS**. A new tab opens the AWS console on **CloudFormation → Quick create stack**. If it asks you to sign in, use the account you're connecting. 5. In AWS, check the region in the top-right corner, scroll to the bottom of the page and check the box that starts with *"I acknowledge that AWS CloudFormation might create IAM resources"*. 6. Click **Create stack**. 7. Go back to the panel and keep the modal open. It shows *Waiting for the stack to finish on AWS*. 8. In 1 to 2 minutes the stack reaches **CREATE_COMPLETE** and notifies the panel. The panel checks the access, the modal closes on its own and the provider shows up in the list with the account number. You don't need to copy anything. To check, the panel assumes the role and tests the EC2 permission, without creating anything. If you close the modal earlier, the connection is still created: reload the page after a few minutes. ![Connect AWS modal waiting for the stack to finish](https://ployter.com/assets/docs/en/aws-auto-waiting.webp) ### If the panel doesn't connect on its own The stack's notice may not arrive, for example when the account blocks Lambda functions. In that case, connect by pasting the RoleArn: 1. In the modal, click **Didn't connect? Paste the RoleArn**. If the panel already tried and failed, the field shows up on its own, with the reason. 2. In AWS, open the stack's **Outputs** tab and copy the **RoleArn** value. It has this format: `arn:aws:iam::123456789012:role/infra/...`. 3. Paste the value into the **Paste the RoleArn** field and click **Connect**. ![Connect AWS modal on the Via link tab](https://ployter.com/assets/docs/en/aws-connect-modal.webp) > [!WARNING] > The link is valid for 24 hours and works for a single connection. If you click **Open again**, the panel generates a new link with a different identifier. In that case, create the stack from the **most recent** link. A stack from an older link doesn't connect, and its RoleArn doesn't work with the new link. ### Default region The default region is the one preselected when you create a server or a database in this account. You can create in any of the available regions, not just the default one: | Region | Code | |---|---| | N. Virginia | `us-east-1` | | Ohio | `us-east-2` | | Oregon | `us-west-2` | | São Paulo | `sa-east-1` | | Ireland | `eu-west-1` | | Frankfurt | `eu-central-1` | The link opens CloudFormation in the chosen default region. The role belongs to IAM, which is global: it works in every region, no matter where the stack was created. ### What the stack creates The stack creates only IAM resources. No machine is created at this point and the stack costs nothing. - **Panel role** (path `/infra/`): the role the panel uses. Only the platform's AWS account can assume it, and only with the ExternalId generated for your connection. Without that identifier, not even someone who finds out the ARN can use it. Each session lasts at most 1 hour. - **Notice function** (`InfraNotifyFunction`, Lambda): runs once when the stack finishes and sends the panel the role ARN and the connection identifier. It has no access to anything in the account besides its own logs. It reports success to CloudFormation even if the panel doesn't answer, so the stack never gets stuck because of it. - **RDS Proxy role** (`infra-rds-proxy-...`): used by the connection pools the panel creates. It can only read the `infra-*` secrets in Secrets Manager. - **Bucket permissions boundary** (`infra-bucket-boundary-...`): the permissions limit for the IAM users the panel creates to hand out each bucket's key. These users never get more than S3 access to the `infra-*` buckets, even if their own policy is broader. The role's permissions cover only what the panel does: | Group | What it allows | |---|---| | EC2 | Create and destroy instances, security groups and static IPs (Elastic IP), and tag them | | Network | Create and remove VPCs, subnets, Internet Gateways and route tables | | Databases and cache | Create, modify, reboot and remove RDS instances, Aurora clusters and ElastiCache groups, with snapshots, parameter groups, replicas and logs | | Connection pools | Create and modify RDS Proxy and its `infra-*` secrets | | Buckets | Create, configure and empty `infra-*` buckets in S3, and the `/infra/` IAM users for bucket keys | | Load balancers and certificates | Create and modify Application Load Balancers and request certificates in ACM | | Read | The Ubuntu image published by Canonical (SSM), CloudWatch metrics | ### What the panel creates later in your account As you use it, the panel creates the following in your account, always with the panel's names and tags: - **Servers**: an EC2 instance with Ubuntu 24.04, a gp3 disk, IMDSv2 required and its own security group (ports 80 and 443 open; 22 only if you provide an SSH key pair). With **Static IP**, also an Elastic IP. See [Servers](https://ployter.com/en/docs/servers/servers/). - **Network**: one VPC per region (`10.80.0.0/16`), with 2 public subnets, 2 private ones, an Internet Gateway and two security groups. See [Private network and firewall](https://ployter.com/en/docs/servers/networking/). - **Managed resources**: RDS and Aurora databases, ElastiCache, S3 buckets and RDS Proxy pools, when you create them. See [Managed cloud databases](https://ployter.com/en/docs/databases/managed/). - **Load balancer**: one Application Load Balancer per project, when a service with a domain gets replicas. See [Replicas and load balancer](https://ployter.com/en/docs/scaling/replicas/). ## Connect with an access key Use this method if your organization doesn't allow creating CloudFormation stacks. The panel stores the key encrypted, but it's still a permanent key: prefer the link whenever you can. ### 1. Create the panel policy 1. In the AWS console, open **IAM → Policies** and click **Create policy**. 2. Switch the editor to **JSON** and paste the contents of `infra-iam-policy.json`, further down this page. 3. Click **Next**, name it `infra-iam-policy` and click **Create policy**. ### 2. Create the bucket permissions boundary You only need this if you'll create buckets. The panel looks for a policy whose name starts with `infra-bucket-boundary`. 1. In **IAM → Policies**, click **Create policy** again. 2. In the **JSON** editor, paste: ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": [ "arn:aws:s3:::infra-*", "arn:aws:s3:::infra-*/*" ] } ] } ``` 3. Name it `infra-bucket-boundary` and click **Create policy**. ### 3. Create the user and key 1. Open **IAM → Users** and click **Create user**. Give it a name, such as `ployter-painel`. Don't check console access. 2. In **Set permissions**, pick **Attach policies directly**, check `infra-iam-policy` and finish creating the user. 3. Open the user, go to **Security credentials** and click **Create access key**. 4. Pick the **Third-party service** use case and finish. 5. Copy the **Access key ID** and the **Secret access key**. The secret is shown only once. ### 4. Paste the key into the panel 1. Open **Integrations → Cloud providers** and click **Connect AWS**. 2. Open the **Access key** tab. 3. Fill in **Name** and **Default region**. 4. Paste the **Access key ID** (starts with `AKIA`) and the **Secret access key**. 5. Click **Connect**. ![Connect AWS modal on the Access key tab](https://ployter.com/assets/docs/en/aws-connect-keys.webp) > [!NOTE] > With a key connection, database connection pooling (RDS Proxy) doesn't work: it depends on the role that only the link's stack creates. ### Contents of infra-iam-policy.json This policy has the same permissions as the link's role, minus the connection pool ones: ```json { "Version": "2012-10-17", "Statement": [ { "Sid": "InfraEc2", "Effect": "Allow", "Action": [ "ec2:RunInstances", "ec2:TerminateInstances", "ec2:DescribeInstances", "ec2:CreateSecurityGroup", "ec2:DeleteSecurityGroup", "ec2:DescribeSecurityGroups", "ec2:AuthorizeSecurityGroupIngress", "ec2:AllocateAddress", "ec2:AssociateAddress", "ec2:DisassociateAddress", "ec2:ReleaseAddress", "ec2:DescribeAddresses", "ec2:CreateTags", "ec2:RevokeSecurityGroupIngress" ], "Resource": "*" }, { "Sid": "InfraNetwork", "Effect": "Allow", "Action": [ "ec2:CreateVpc", "ec2:DeleteVpc", "ec2:DescribeVpcs", "ec2:ModifyVpcAttribute", "ec2:CreateSubnet", "ec2:DeleteSubnet", "ec2:DescribeSubnets", "ec2:ModifySubnetAttribute", "ec2:DescribeAvailabilityZones", "ec2:CreateInternetGateway", "ec2:DeleteInternetGateway", "ec2:AttachInternetGateway", "ec2:DetachInternetGateway", "ec2:DescribeInternetGateways", "ec2:CreateRouteTable", "ec2:DeleteRouteTable", "ec2:DescribeRouteTables", "ec2:CreateRoute", "ec2:AssociateRouteTable", "ec2:DisassociateRouteTable" ], "Resource": "*" }, { "Sid": "InfraManagedDatabases", "Effect": "Allow", "Action": [ "rds:CreateDBInstance", "rds:DeleteDBInstance", "rds:DescribeDBInstances", "rds:ModifyDBInstance", "rds:CreateDBSubnetGroup", "rds:DeleteDBSubnetGroup", "rds:DescribeDBSubnetGroups", "rds:AddTagsToResource", "rds:ListTagsForResource", "rds:CreateDBSnapshot", "rds:DeleteDBSnapshot", "rds:DescribeDBSnapshots", "rds:RestoreDBInstanceFromDBSnapshot", "rds:CreateDBParameterGroup", "rds:DeleteDBParameterGroup", "rds:ModifyDBParameterGroup", "rds:ResetDBParameterGroup", "rds:DescribeDBParameterGroups", "rds:DescribeDBParameters", "rds:DescribeEngineDefaultParameters", "rds:RebootDBInstance", "rds:CopyDBParameterGroup", "rds:CreateDBInstanceReadReplica", "rds:PromoteReadReplica", "rds:FailoverDBCluster", "rds:DescribeDBLogFiles", "rds:DownloadDBLogFilePortion", "rds:CreateDBCluster", "rds:DeleteDBCluster", "rds:DescribeDBClusters", "rds:ModifyDBCluster", "rds:RestoreDBClusterFromSnapshot", "rds:CreateDBClusterSnapshot", "rds:DeleteDBClusterSnapshot", "rds:DescribeDBClusterSnapshots", "rds:CreateDBClusterParameterGroup", "rds:DeleteDBClusterParameterGroup", "rds:ModifyDBClusterParameterGroup", "rds:ResetDBClusterParameterGroup", "rds:DescribeDBClusterParameterGroups", "rds:DescribeDBClusterParameters", "rds:DescribeEngineDefaultClusterParameters", "rds:DescribeDBEngineVersions", "rds:DescribePendingMaintenanceActions", "rds:ApplyPendingMaintenanceAction", "elasticache:CreateReplicationGroup", "elasticache:DeleteReplicationGroup", "elasticache:DescribeReplicationGroups", "elasticache:ModifyReplicationGroup", "elasticache:CreateCacheSubnetGroup", "elasticache:DeleteCacheSubnetGroup", "elasticache:DescribeCacheSubnetGroups", "elasticache:DescribeCacheClusters", "elasticache:AddTagsToResource", "elasticache:CreateSnapshot", "elasticache:DeleteSnapshot", "elasticache:DescribeSnapshots", "elasticache:CreateCacheParameterGroup", "elasticache:DeleteCacheParameterGroup", "elasticache:ModifyCacheParameterGroup", "elasticache:ResetCacheParameterGroup", "elasticache:DescribeCacheParameterGroups", "elasticache:DescribeCacheParameters", "elasticache:DescribeEngineDefaultParameters" ], "Resource": "*" }, { "Sid": "InfraServiceLinkedRoles", "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "*", "Condition": { "StringEquals": { "iam:AWSServiceName": [ "rds.amazonaws.com", "elasticache.amazonaws.com", "elasticloadbalancing.amazonaws.com" ] } } }, { "Sid": "InfraEncryptionDefaultKeys", "Effect": "Allow", "Action": [ "kms:DescribeKey", "kms:CreateGrant" ], "Resource": "*", "Condition": { "StringLike": { "kms:ViaService": [ "rds.*.amazonaws.com", "elasticache.*.amazonaws.com" ] } } }, { "Sid": "InfraUbuntuImage", "Effect": "Allow", "Action": "ssm:GetParameter", "Resource": "arn:aws:ssm:*::parameter/aws/service/canonical/*" }, { "Sid": "InfraMetrics", "Effect": "Allow", "Action": "cloudwatch:GetMetricData", "Resource": "*" }, { "Sid": "InfraBuckets", "Effect": "Allow", "Action": [ "s3:CreateBucket", "s3:DeleteBucket", "s3:ListBucket", "s3:ListBucketVersions", "s3:PutBucketTagging", "s3:PutBucketVersioning", "s3:PutBucketCORS", "s3:GetLifecycleConfiguration", "s3:PutLifecycleConfiguration", "s3:PutBucketPolicy", "s3:DeleteBucketPolicy", "s3:PutBucketPublicAccessBlock", "s3:DeleteObject", "s3:DeleteObjectVersion" ], "Resource": [ "arn:aws:s3:::infra-*", "arn:aws:s3:::infra-*/*" ] }, { "Sid": "InfraBucketUsersCreate", "Effect": "Allow", "Action": [ "iam:CreateUser", "iam:PutUserPolicy" ], "Resource": "arn:aws:iam::*:user/infra/*", "Condition": { "StringLike": { "iam:PermissionsBoundary": "arn:aws:iam::*:policy/*infra-bucket-boundary*" } } }, { "Sid": "InfraBucketUsersManage", "Effect": "Allow", "Action": [ "iam:GetUser", "iam:TagUser", "iam:DeleteUser", "iam:DeleteUserPolicy", "iam:CreateAccessKey", "iam:DeleteAccessKey", "iam:ListAccessKeys" ], "Resource": "arn:aws:iam::*:user/infra/*" }, { "Sid": "InfraFindBoundary", "Effect": "Allow", "Action": "iam:ListPolicies", "Resource": "*" }, { "Sid": "InfraLoadBalancers", "Effect": "Allow", "Action": [ "elasticloadbalancing:CreateLoadBalancer", "elasticloadbalancing:DeleteLoadBalancer", "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:CreateListener", "elasticloadbalancing:DeleteListener", "elasticloadbalancing:ModifyListener", "elasticloadbalancing:DescribeListeners", "elasticloadbalancing:AddListenerCertificates", "elasticloadbalancing:RemoveListenerCertificates", "elasticloadbalancing:DescribeListenerCertificates", "elasticloadbalancing:CreateRule", "elasticloadbalancing:DeleteRule", "elasticloadbalancing:ModifyRule", "elasticloadbalancing:DescribeRules", "elasticloadbalancing:CreateTargetGroup", "elasticloadbalancing:DeleteTargetGroup", "elasticloadbalancing:ModifyTargetGroup", "elasticloadbalancing:ModifyTargetGroupAttributes", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:RegisterTargets", "elasticloadbalancing:DeregisterTargets", "elasticloadbalancing:DescribeTargetHealth", "elasticloadbalancing:AddTags", "ec2:DescribeSubnets", "ec2:DescribeVpcs", "ec2:DescribeInternetGateways", "ec2:DescribeAccountAttributes" ], "Resource": "*" }, { "Sid": "InfraCertificates", "Effect": "Allow", "Action": [ "acm:RequestCertificate", "acm:DescribeCertificate", "acm:DeleteCertificate", "acm:AddTagsToCertificate" ], "Resource": "*" } ] } ``` ## After connecting The account shows up as a card in **Integrations → Cloud providers**, with: - **Account**: the AWS account number. - **Access**: **Role (link)** in green, or **Key AKIA...** in yellow, as a reminder that a permanent key exists. - **Default region** and the number of **Servers**. - **Networks**: the VPCs the panel created or started using. The network is created automatically with the first server in each region. ![Connected AWS provider card](https://ployter.com/assets/docs/en/aws-provider-card.webp) In the card's **⋮** menu: - **Edit**: changes the name and default region. - **Change access**: replaces the credential without losing the servers. Use it to move from a key to the link, or to recreate the stack. - **Remove**: removes the provider from the panel (see below). If you have another team with integrations and you own both, the **Import from another team** button copies the provider without redoing the connection. ## Update permissions When the panel gains a new feature, the role may need new permissions. In that case, an operation fails with a message like *"The credential doesn't have permission for this operation. If the account was connected via link, update the stack with the new template"*. To update a link connection: 1. On the provider card, open **⋮ → Change access**. 2. On the **Via link (recommended)** tab, click **Open AWS** and create the new stack, with the current template. 3. Go back to the panel and wait: when the new stack finishes, the access is replaced on its own. If it isn't, paste the new RoleArn and click **Change access**. 4. In CloudFormation, delete the old stack. For a key connection, edit the `infra-iam-policy` policy in IAM and paste the updated contents from this page. ## Remove access 1. First delete the servers in this account. If there are servers, the panel warns: *"There are N server(s) in this account. Delete the servers first."* 2. Remove the networks from the card (trash icon next to each network). A network can only be removed when it has no servers, managed databases or load balancer in it. 3. Open **⋮ → Remove** and confirm. The panel forgets the access to the account. 4. In AWS, actually revoke the access: - **Via link**: open **CloudFormation → Stacks**, select the panel's access stack (its name has `-access-` followed by six characters) and click **Delete**. The role and policies go with it. - **With a key**: open **IAM → Users**, pick the user, go to **Security credentials** and deactivate (**Deactivate**) or delete the key. > [!WARNING] > Don't delete the stack before removing the servers and resources through the panel. Without the role, the panel loses access, and what it created stays in your account, billing, until you delete it by hand. ## Common problems | Message | What to do | |---|---| | *The stack reported back, but the access was not accepted* | The role wasn't valid yet or the stack was changed. Paste the RoleArn from the **Outputs** tab into the field that shows up. If it keeps failing, delete the stack and connect again. | | *The panel is already connecting this account on its own* | The stack already reported back and the panel is checking the access. Wait a few seconds. | | *AWS refused to assume the role: check the pasted ARN and whether the stack finished creating* | Wait for the **CREATE_COMPLETE** status and check that the RoleArn comes from the stack created by the most recent link. | | *Connection link expired or already used* | The link is older than 24 hours or was already used. Click **Open again** and create a new stack. | | *Invalid Access Key ID* or *Incorrect Secret Access Key* | Check the copied key. The secret is shown only once: if you lost it, create another key in IAM. | | *The credential doesn't have permission for this operation* | Update the permissions, as in the **Update permissions** section above. | | *The account reached the region's VPC limit* | AWS allows 5 VPCs per region by default. Use an existing VPC or request an increase in **Service Quotas**. |