Connect
Connect AWS from the terminal. Pass --help for the flags AWS accepts, plus --no-browser for headless environments.
polylane cloud connect --provider awsCloudFormation stack that creates an IAM role for Polylane.
Connect an AWS account with a CloudFormation stack. The stack creates an IAM role that Polylane assumes from its own AWS account. The role reads your account, manages the resources that Polylane creates, and can add Polylane to your CloudWatch alarms.
- Enter your 12-digit AWS Account ID.
- Select the AWS Region to connect.
- Leave Investigate alarms on to have Polylane investigate your CloudWatch alarms.
- Click Deploy stack on AWS. The CloudFormation console opens with the template loaded.
- Review the template and click Create stack.
- Return to Polylane. The stack reports the role to Polylane, and the first sync starts.
The template is open, so you can examine each permission before you create the stack.
The stack creates these items:
- The IAM role
PolylaneEnvironmentRoleand its inline policy. - A multi-region CloudTrail trail that records write events, and an S3 bucket for its logs.
- An SNS topic that receives CloudTrail and CloudWatch alarm notifications for Polylane.
- A custom resource that registers the account with Polylane when the stack is created.
Connect AWS from a CI job or any other environment without a browser.
The guided flow ends with a CloudFormation quick-create link that someone opens in the AWS console. If your AWS accounts only change through code review and a pipeline, nobody is there to click it. The same connection fits entirely in a CI job: one API call creates the connection and generates a CloudFormation template, your own tooling deploys the template, and the stack registers the account with Polylane by itself.
If you only want the template YAML, the console's connect dialog also shows it inline under Advanced, with Copy and Download buttons. The flow below needs no console at all.
Prerequisites
- A Polylane API key with the
cloud_accounts:writeandcloud_accounts:readscopes. See API keys and OAuth. - Your workspace ID, which starts with
ws_. Read it fromGET /v1/workspaceswith the same key. - AWS credentials in the pipeline that can deploy CloudFormation stacks and create IAM roles in the account you are connecting.
Create the connection
curl -X POST https://api.polylane.com/v1/cloud_accounts \
-H "x-api-key: $POLYLANE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "aws",
"workspaceId": "ws_0abc123",
"account": "123456789012",
"regions": ["us-east-1", "eu-west-1"]
}'
account is the 12-digit AWS account ID. regions lists the regions Polylane scans on each sync; pass null to scan every region enabled on the account, resolved at each sync. Two optional booleans, createMonitoringAlarms and subscribeToAlarms, control the default alarms and alarm investigation described in How it works, and default to true.
The response carries everything the rest of the flow needs:
{
"success": true,
"result": {
"provider": "aws",
"url": "https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?...",
"s3Url": "https://....s3.amazonaws.com/...?X-Amz-Expires=3600&...",
"region": "us-east-1",
"templateBody": "Description: This template creates the resources necessary for Polylane to observe your AWS Account\n..."
}
}
result.templateBodyis the CloudFormation template generated for this connection, inline, so a job can write it straight to a file.result.s3Urlis a presigned link to the same template. It expires after one hour.result.regionis the region to deploy the stack in. The template is generated for exactly this region.result.urlis the console quick-create link the guided flow uses. Ignore it here.
A 409 means the account is already connected. Change an existing connection's regions with PATCH /v1/cloud_accounts/{workspaceId}/{id} instead of reconnecting.
Write the template to a file
Write result.templateBody to a file, or download the presigned link:
curl -o polylane-connector.yaml "<result.s3Url>"
The template arrives ready to deploy. Its ExternalParameter parameter defaults to an external ID generated for this connection: it becomes the sts:ExternalId condition on the role the stack creates, and Polylane presents the same ID every time it assumes that role. Deploy the file exactly as generated and leave the parameter defaults alone. A stack with an edited external ID deploys fine but can never register.
That external ID is also why the file deserves credential handling: keep it inside the pipeline run rather than committing it or publishing it as a build artifact.
If the presigned link expires before you deploy, call the connect endpoint again for a fresh template. Repeating the call is safe until the account registers; after that it returns a 409.
Deploy the stack
aws cloudformation deploy \
--stack-name PolylaneConnector \
--template-file polylane-connector.yaml \
--capabilities CAPABILITY_IAM \
--region us-east-1
Use the region from step 1. CAPABILITY_IAM acknowledges the IAM role the stack creates; the role itself is unnamed, and a named inline policy does not require CAPABILITY_NAMED_IAM, so CAPABILITY_IAM suffices.
The stack creates the role Polylane assumes (read-only access plus operations on polylane-prefixed resources), its inline policy, a CloudTrail trail writing to a new S3 bucket, an SNS topic for trail and alarm notifications, and a reporter custom resource. The reporter is what registers the connection: it hands Polylane the role ARN while the stack is being created, so there is no callback to configure and nothing else to run.
The same deploy from Terraform:
resource "aws_cloudformation_stack" "polylane_connector" {
name = "PolylaneConnector"
template_body = file("${path.module}/polylane-connector.yaml")
capabilities = ["CAPABILITY_IAM"]
}
Point the provider, or a provider alias, at the region from step 1. Reference the saved file with template_body rather than handing s3Url to template_url: the presigned link outlives neither the hour nor your next plan, so fetch the template in the same run that applies it.
Watch the account come online
The account appears once the stack's reporter reaches Polylane, normally moments after the stack completes. Poll it by its natural key, which returns 404 until registration lands and 200 after:
until curl -sf "https://api.polylane.com/v1/cloud_accounts/ws_0abc123/aws/123456789012/us-east-1" \
-H "x-api-key: $POLYLANE_API_KEY" > /dev/null; do
sleep 15
done
Give the loop a deadline so a failed deploy fails the job instead of hanging it. Once the account exists, its status field is new on registration, syncing while a sync runs, and ready when the sync completes.
curl -s "https://api.polylane.com/v1/cloud_accounts/ws_0abc123/aws/123456789012/us-east-1" \
-H "x-api-key: $POLYLANE_API_KEY" | jq -r '.result.status'
From here the account behaves exactly like one connected from the console: resources sync into the topology, Polylane runs its first check on its own, and the account page fills in.
Disconnect from the API
Deleting the connection also deletes the CloudFormation stack in your account. The call needs the cloud_accounts:delete scope:
curl -X DELETE https://api.polylane.com/v1/cloud_accounts/ws_0abc123/<cloud-account-id> \
-H "x-api-key: $POLYLANE_API_KEY"
The role, its policy, and the CloudTrail S3 bucket carry DeletionPolicy: Retain, so they survive the stack deletion. Remove them yourself if you want the AWS account fully clean.
How it works
Access
Polylane assumes the role with an external ID that is unique to your connection. On connect, Polylane also adds an EKS access entry for the role to each EKS cluster, with the view-only AmazonEKSAdminViewPolicy, so that it can read your Kubernetes workloads.
Infrastructure graph
Polylane maps about 75 resource types in each region that you select, for example Lambda, ECS, EKS, EC2 and VPC networks, RDS, DynamoDB, S3, SQS, SNS, API Gateway, CloudFront, load balancers, ElastiCache, Step Functions and EventBridge.
The CloudTrail trail drives the sync. When a person or a deploy changes a resource, Polylane syncs that region. Changes that AWS services make, such as ECS task churn, go to a slower sync. An automatic sync runs at most once every 30 minutes. You can also sync the account from its page.
Metrics, logs and checks
Polylane reads CloudWatch metrics, CloudWatch Logs Insights and X-Ray traces. Every 30 minutes by default, it checks CloudWatch metrics for Lambda, RDS, load balancers, API Gateway, ECS, DynamoDB, SQS and other services. Account checks look for root-user activity, spikes in AccessDenied errors, and X-Ray error rate and latency. Your CloudWatch metric alarms and saved Logs Insights queries also become checks.
Alarms
When Investigate alarms is on, Polylane adds its SNS topic to the alarm and OK actions of each CloudWatch metric alarm. When you create an alarm later, CloudTrail tells Polylane, and Polylane adds the topic to it. The alarm keeps its threshold and its other actions.
Each alarm that fires becomes an issue, and a new issue starts an investigation. Polylane ignores alarms that only drive autoscaling. When the alarm goes back to OK, Polylane adds the recovery to the issue as evidence. The Alerts tab of the account has a switch for each alarm.
With createMonitoringAlarms set, Polylane also creates default alarms named Polylane-<Service>-<Metric> for errors, throttles, latency and saturation in each monitored region. It sets their thresholds from the last seven days of data.
Agents and writes
During an investigation, agents read AWS APIs, CloudWatch metrics and logs, X-Ray traces and EKS workloads. The account starts as Read-only in Polylane. A workspace admin can turn it off, so that agents can request writes: create a polylane- alarm or dashboard, mute or unmute an alarm, or scale, restart or patch an EKS workload. Each write needs a safety review and your approval before it runs.
Permissions
The IAM role has these permissions:
- The AWS-managed
ReadOnlyAccesspolicy. The role cannot read S3 objects, except in the bucket of the stack. It cannot read DynamoDB items, DAX, S3 Tables or S3 Vectors data. - Full control of the CloudTrail trail, S3 bucket and SNS topic of the stack.
- Changes to Lambda functions, SNS topics and CloudWatch dashboards whose names start with
polylane-. - Write access to every CloudWatch alarm in the account. The role can create or replace an alarm (
PutMetricAlarmreplaces the full alarm configuration) and mute or unmute an alarm. Polylane uses this access to add or remove its SNS topic, and to mute or unmute an alarm when you ask it to. - Deletion only of alarms whose names start with
Polylane-orpolylane-. - Tag reads and changes on resources.
- Cost Explorer reads.
- An EKS access entry for the role itself, limited to
AmazonEKSAdminViewPolicyat cluster scope.
Disconnecting
Disconnect the account in Polylane. Polylane deletes its default alarms, removes its SNS topic from your alarms, removes the account from the infrastructure graph, and deletes the CloudFormation stack. You can also delete the stack yourself in CloudFormation, which disconnects the account.
The IAM role, its policy, the CloudTrail S3 bucket and the EKS access entries stay after the stack is deleted. Delete them yourself to remove all access. Alarms and dashboards that agents created with a polylane- name also stay.
Disconnect
Disconnecting stops every sync and check and deletes the credentials Polylane held. Polylane removes what AWS's API lets it remove. The following stays until you remove it yourself:
- PolylaneEnvironmentRole (DeletionPolicy Retain)
- PolylaneEnvironmentPolicies (Retain)
- PolylaneS3Bucket (Retain)
- EKS access entries
polylane cloud disconnect <id>Tools
11Operations agents can perform in threads.
Supported resources
77Resource types that show up in your infrastructure graph.