Provider Connectors
Single account
Connect one AWS account to LevelFour in a click from the dashboard, with a CloudFormation Launch Stack link, or with Terraform. Covers the two IAM roles the stack creates and how to revoke them.
LevelFour reads your AWS costs through IAM roles it creates in your account. You can connect one account from the dashboard in a click, with a CloudFormation Launch Stack link, or with Terraform. Each path takes its values from the dashboard, and the account connects without you sending LevelFour anything.
If your accounts sit under AWS Organizations, the multi-account path onboards every one of them in a single deployment.
Self-service path (recommended)
The whole flow runs from the LevelFour dashboard without an onboarding contact in the loop. Go to Add Provider > AWS in the dashboard (https://dashboard.levelfour.ai/add-provider/aws) and click Connect via AWS Console. After your first account connects, add the next one from Settings > Connected Providers > AWS > Add account. The dashboard opens AWS Console with the v2 CloudFormation template pre-loaded. Click Create stack, and the deployed stack pings LevelFour.
Prerequisites
- An AWS account with permission to create IAM roles and CloudFormation stacks (typically an admin role)
- Three values from the dashboard's Terraform method: the handshake ID, the integration ID and the pingback topic ARN. Open Add Provider > AWS (
https://dashboard.levelfour.ai/add-provider/aws), or Settings > Connected Providers > AWS > Add account after your first account connects, and pick Terraform. Only an admin of your LevelFour organization sees the values.
.tfvars file that holds the ID. If it leaks, click Rotate key in the Terraform method. Accounts you already connected stay connected.Deploy with a Launch Stack link
Use these steps when the person who holds AWS access cannot open the LevelFour dashboard. A LevelFour admin copies the three values from the dashboard's Terraform method and sends them to that person.
Open the Launch Stack link
Sign in to the AWS account you want to onboard, then click the Launch Stack link below. It opens the CloudFormation console with the LevelFour onboarding template pre-loaded.
https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/quickcreate?templateURL=https://cf-templates-1bsphth8u70q9-us-east-1.s3.amazonaws.com/onboarding/v2/onboarding-levelfour-cloudformation-template.json&stackName=LevelFourRegion does not matter for IAM resources. Leave it on us-east-1.
Enter the LevelFour values
CloudFormation shows the template's parameters. Paste each value from the dashboard:
- LevelFourHandshakeID: the handshake ID
- IntegrationID: the integration ID
- PingbackTopicArn: the pingback topic ARN
Leave the stack name as LevelFour, or change it if your team uses a naming convention.
CREATE_COMPLETE and the account never shows as Connected. Paste the value, do not retype it.Acknowledge the IAM capability
At the bottom of the page, tick:
I acknowledge that AWS CloudFormation might create IAM resources with custom names.
AWS asks for this because the template creates roles with specific names (LevelFourCrossAccountRole, plus an empty LevelFourSavingsExec role for Automated Savings) rather than letting AWS auto-generate them. Predictable names let LevelFour find the roles without you copying ARNs back to LevelFour.
Click Create stack.
Wait for the account to connect
CloudFormation provisions the roles in 30 to 60 seconds. Watch the Events tab for progress. Once the roles exist, the stack sends LevelFour your account ID, and LevelFour checks the role with an sts:AssumeRole call that carries your handshake ID.
CREATE_COMPLETE, the account shows as Connected under Settings > Connected Providers > AWS, and LevelFour starts ingesting its cost data.The stack's Outputs tab lists:
- RoleArn:
arn:aws:iam::<your-account-id>:role/LevelFourCrossAccountRole - SavingsExecRoleArn:
arn:aws:iam::<your-account-id>:role/LevelFourSavingsExec(the Automated Savings execution role) - HandshakeID: the same value you entered, echoed back for verification
Deploy with Terraform
Use this path when you manage the account as code. Terraform deploys the same LevelFour template through an aws_cloudformation_stack resource. The roles and their permissions match the Launch Stack link, the stack lives in your Terraform state, and the account connects on its own once the apply finishes.
Add the stack to your configuration
Point the AWS provider at the account you want to onboard. allowed_account_ids stops Terraform before it changes anything in a different account. If your configuration already has a provider for this account, keep yours and leave this one out.
provider "aws" {
region = "us-east-1"
allowed_account_ids = ["<your-account-id>"]
}
variable "levelfour_handshake_id" {
description = "Handshake ID from the LevelFour dashboard, Terraform method"
type = string
sensitive = true
}
variable "levelfour_integration_id" {
description = "Integration ID from the LevelFour dashboard, Terraform method"
type = string
sensitive = true
}
variable "levelfour_pingback_topic_arn" {
description = "Pingback topic ARN from the LevelFour dashboard, Terraform method"
type = string
sensitive = true
}
resource "aws_cloudformation_stack" "levelfour" {
name = "LevelFour"
template_url = "https://cf-templates-1bsphth8u70q9-us-east-1.s3.amazonaws.com/onboarding/v2/onboarding-levelfour-cloudformation-template.json"
capabilities = ["CAPABILITY_NAMED_IAM"]
parameters = {
LevelFourHandshakeID = var.levelfour_handshake_id
IntegrationID = var.levelfour_integration_id
PingbackTopicArn = var.levelfour_pingback_topic_arn
}
}
output "levelfour_role_arn" {
value = aws_cloudformation_stack.levelfour.outputs["RoleArn"]
}
output "levelfour_savings_exec_role_arn" {
value = aws_cloudformation_stack.levelfour.outputs["SavingsExecRoleArn"]
}CAPABILITY_NAMED_IAM is the acknowledgement the console asks for, because the template creates LevelFourCrossAccountRole and LevelFourSavingsExec by name. IntegrationID and PingbackTopicArn make the stack tell LevelFour your account ID once the roles exist. Leave them out and the roles still deploy, but the account never connects.
Apply with the dashboard values
Copy the three values from the dashboard's Terraform method and pass them through environment variables, so they stay out of your .tf and .tfvars files:
export TF_VAR_levelfour_handshake_id='<from the dashboard>'
export TF_VAR_levelfour_integration_id='<from the dashboard>'
export TF_VAR_levelfour_pingback_topic_arn='<from the dashboard>'
terraform init
terraform applyterraform apply returns once the stack reaches CREATE_COMPLETE, 30 to 60 seconds later. If CloudFormation rolls the stack back, the apply fails and prints the stack's error.
Check the account in the dashboard
Run terraform output to see both role ARNs:
- levelfour_role_arn:
arn:aws:iam::<your-account-id>:role/LevelFourCrossAccountRole - levelfour_savings_exec_role_arn:
arn:aws:iam::<your-account-id>:role/LevelFourSavingsExec(the Automated Savings execution role)
Onboarding more accounts
Repeat the deploy in each additional AWS account with the same three values. They stay valid until someone rotates the key, so an account you add months later connects the same way. Each account gets its own role with the same predictable name. With Terraform, that is one aws_cloudformation_stack per account, each under a provider for that account.
Past three or four accounts, switch to the multi-account path.
What the stack creates
The stack creates two roles. Both trust LevelFour's AWS account (730335248431) and only accept AssumeRole requests that carry the LevelFourHandshakeID as the external ID.
LevelFourCrossAccountRole is the read-only role LevelFour uses to analyze your costs. Its permissions:
- AWS managed
ReadOnlyAccess(read-only access to all resources) - A focused inline policy covering: Cost Explorer, Compute Optimizer, Cost Optimization Hub, Savings Plans, Pricing, AWS Support, Trusted Advisor, S3 Storage Lens, BCM Data Exports, Container Insights, and the IAM service-linked role creation needed to enroll in those services
LevelFourSavingsExec is created empty, with no attached permissions. It exists so that, when you approve a specific Automated Savings action, a scoped policy covering only that action and its resources is attached for a short, time-limited window and then expires on its own. Nothing in your account can be changed until you explicitly approve such an action.
With IntegrationID and PingbackTopicArn set, the stack also holds a LevelFourPingback custom resource, which grants no permissions. When you create, update or delete the stack, it sends the LevelFour pingback topic your account ID, the stack ID and the role ARN. LevelFour uses that message to check the role and connect the account.
You can review the full template before deploying:
https://cf-templates-1bsphth8u70q9-us-east-1.s3.amazonaws.com/onboarding/v2/onboarding-levelfour-cloudformation-template.jsonRemoving access
To revoke LevelFour's access to an account, delete the CloudFormation stack:
aws cloudformation delete-stack --stack-name LevelFourThis removes both roles (LevelFourCrossAccountRole and LevelFourSavingsExec). LevelFour stops being able to read data from that account immediately.
If you deployed with Terraform, remove the aws_cloudformation_stack.levelfour resource, its two outputs and the three levelfour_* variables from your configuration, then run terraform apply. Do not delete the stack with the AWS CLI instead: the resource is still in your configuration, so the next terraform apply creates the stack again.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
CREATE_FAILED, "Role with name LevelFourCrossAccountRole already exists" | The LevelFour role is already deployed in this account | Skip it, the account is already onboarded. To redeploy, delete the existing role first |
CREATE_FAILED with an SCP-related error | Service Control Policies in your AWS Organization block IAM role creation in this account | Ask your AWS administrator to permit iam:CreateRole, iam:AttachRolePolicy and iam:PutRolePolicy for the role name LevelFourCrossAccountRole |
terraform apply fails with Requires capabilities : [CAPABILITY_NAMED_IAM] | The aws_cloudformation_stack resource has no capabilities argument | Add capabilities = ["CAPABILITY_NAMED_IAM"] and apply again |
The stack reached CREATE_COMPLETE, but the account never appears in the dashboard | You deployed the stack without IntegrationID and PingbackTopicArn, so it never told LevelFour about the account | Add both parameters, as in the Terraform snippet above, set them to the values from the dashboard's Terraform method, and apply again. CloudFormation adds the pingback resource, and the account connects about a minute later |
| The stack succeeded, but LevelFour cannot assume the role | The handshake ID you entered does not match the one in the dashboard | Update the stack and paste the correct value. With Terraform, export the correct TF_VAR_levelfour_handshake_id and apply again |
CREATE_FAILED or UPDATE_FAILED on LevelFourPingback, saying the LevelFour Terraform key was rotated | Someone rotated the key in the dashboard after you copied the integration ID | Copy the current integration ID from the dashboard's Terraform method, export it as TF_VAR_levelfour_integration_id (or paste it into the stack's IntegrationID parameter), and apply again. Accounts connected before the rotation stay connected |
CREATE_FAILED on LevelFourPingback with an unknown integration ID | The integration ID was mistyped | Copy the integration ID again from the dashboard's Terraform method and apply again |
| The accounts table says "No Organizations access" in the OU column | LevelFourCrossAccountRole cannot call organizations:DescribeOrganization: a Service Control Policy denies it, or the role came from an edited template without ReadOnlyAccess | Update the stack to the current template, or allow organizations:Describe* and organizations:List* for LevelFourCrossAccountRole. LevelFour reads the account's organization again within a day |
LevelFour cannot assume the role
Every 6 hours LevelFour assumes LevelFourCrossAccountRole in each connected account. When AWS refuses it, the account shows Error under Settings > Connected Providers > AWS, and its page names the code AWS returned, such as AccessDenied. One of these changed in the account:
- The role was deleted, or the stack that created it was.
- The role's trust policy no longer trusts LevelFour.
- The trust policy's external ID no longer matches your handshake ID.
Until the role answers, LevelFour cannot read the account or act on it through the role. To put it back, click Reconnect the account on the account's page and deploy the stack again, with the Launch Stack link or with Terraform as above. If the old stack still exists in the account, update it with the dashboard's values rather than creating a second one, since the role names are fixed. The account shows Connected again at the next check, within 6 hours.
Next
- Detailed cost data turns on the Cost and Usage Report, which is what gives you resource-level and tag-level breakdowns
- Automated Savings covers the
LevelFourSavingsExecrole, including accounts onboarded before it existed
Connect AWS
Pick the AWS path that matches your account layout, then add detailed cost data and Automated Savings when you want them.
Multi-account
Onboard every AWS account in your organization at once, from the dashboard or by deploying one CloudFormation StackSet in the management account, by hand or with Terraform.