Connect AWS (CloudFormation)

Deploy the generated CloudFormation template, choose organization or single account and optional features, then verify.

Connect AWS (CloudFormation)

Give CostGlass read-only access to your AWS bill by deploying one CloudFormation template that CostGlass generates for you.

Where in CostGlassSettings → Cloud Accounts → Connect a New Cloud Account or Platform
PlanAll plans
Who can do thisOwner or Admin in CostGlass; someone who can create IAM roles and CloudFormation stacks in AWS
Time neededAbout 10 minutes, plus up to 24 hours for the first data
In short
  • You deploy one template in AWS region us-east-1. It creates a Cost and Usage export, an S3 bucket for it, and a role named CostGlassCURReader that only CostGlass can assume.
  • Choose AWS Organization (deploy once in the management account, member accounts follow) or Single account.
  • Instance Scheduler, Rightsizing and Uptime are optional. A feature you do not tick is left out of the template completely.
  • Only Instance Scheduler can change anything in your account (start and stop). Everything else is read-only.
  • AWS needs up to 24 hours to deliver the first export. CostGlass picks it up automatically.
Before you begin
  • A login to AWS. For an AWS Organization, the management (payer) account. For a single account, the account that pays the bill.
  • Permission in AWS to create CloudFormation stacks that contain IAM resources (named IAM resources).
  • For an Organization: CloudFormation StackSets trusted access enabled (a one-time step, explained below).
  • Spare capacity in your plan. See the connection limits in the overview.

How the connection works

CostGlass never asks for an AWS access key. Instead, the template creates an IAM role in your account. A role is a set of permissions that a trusted outsider can borrow for a short time. The role trusts only the CostGlass AWS account, and only when it presents your External ID.

External ID
A long random secret generated for this one connection. The role refuses anyone who does not present it. It stops another AWS customer from tricking CostGlass into reading your account.
Cost and Usage export (CUR)
AWS Billing writes a detailed file of every charge, hourly, to an S3 bucket in your account. CostGlass reads those files. This is how your cost data arrives.
StackSet
A CloudFormation feature that rolls the same stack out to many accounts. The Organization template uses one to create the member-account role.

What the template creates:

ResourceNamePurpose
S3 bucketcostglass-cur-exports-<your account ID>Receives the export. Encrypted, all public access blocked. A bucket policy lets AWS Billing write to it.
Cost and Usage exportCostGlassCURExportHourly, with resource IDs, CSV compressed with gzip, into the folder cur.
IAM roleCostGlassCURReaderThe role CostGlass assumes. Trusts the CostGlass account and your External ID.
Organization only: StackSetCostGlass-Organization-Member-RolesCreates a role named CostGlassReadOnly in every member account, including accounts that join later.

Connect AWS, step by step

Cloud Accounts → AWS. The same wizard also appears on the first-run screen.
1
Open the wizard
Go to Settings → Cloud Accounts. In the section Connect a New Cloud Account or Platform click the AWS card under Connect a cloud. (On the first-run screen the wizard is already on AWS.)
2
Choose the account type
Under Account type choose AWS Organization (deploy once in the management account; the role is rolled out to every member account) or Single account (an account that is not part of an Organization).
3
Choose the features
Under Features, Cost & Usage Report (CUR) is always on. Tick any of Instance Scheduler, Rightsizing recommendations and Resource uptime monitoring. Each shows a Read-only or Write access tag and lists its permissions. See the table in the next section.
4
Generate the template
Click Generate my template. CostGlass creates the connection and your External ID. If you leave and come back before finishing, the same pending connection and the same External ID are reused.
5
Download the template
On Deploy the CloudFormation template click Download or Copy template. The page also lists exactly which permissions the template grants. Your External ID is pre-filled inside the file.
6
Switch AWS to us-east-1
In the AWS console, set the region to us-east-1 (N. Virginia). This applies even if all your servers run elsewhere: the Cost and Usage export resource only exists there.
7
Organization only: enable trusted access
One time, from the management account: CloudFormation → StackSets → Enable trusted access with AWS Organizations.
8
Create the stack
In AWS open CloudFormation → Create stack → With new resources → Upload a template file, choose the file, leave the parameters as generated, tick the acknowledgement that IAM resources will be created (CAPABILITY_NAMED_IAM), and create the stack. Wait for CREATE_COMPLETE, usually three to five minutes.
9
Copy the outputs
Open the stack's Outputs tab and copy RoleArn and BucketName.
10
Verify and connect
Back in CostGlass click I have deployed it. Fill in the fields below and click Verify & connect.

The verify form

FieldWhat to enterDefault
Name for this integration (optional)A label you will recognise, for example "Acme production organisation".AWS CUR Export (<account ID>)
Role ARN (Outputs: RoleArn)The RoleArn output. Looks like arn:aws:iam::123456789012:role/CostGlassCURReader.None
S3 bucket (Outputs: BucketName)The BucketName output.None
PrefixThe folder inside the bucket.cur/
RegionThe region of the bucket.us-east-1

CostGlass assumes the role with your External ID and lists the bucket before saving. A typo is rejected here, not a day later.

What you see afterwards

The wizard moves to AWS connected and shows one of these messages:

MessageMeaning
Synced N records from M file(s).Data has already arrived.
The first import is running in the background. Your data will appear in a few minutes.A large export is being read in stages. Nothing for you to do.
Connected. AWS has not delivered the first export yet...Normal on a new setup. Up to 24 hours. CostGlass checks again every 6 hours.
The bucket could not be read yet: ...Read the reason, then see the FAQ below.

Check delivery now runs the check immediately. Integrate another starts a fresh connection.

What each feature adds

Permissions are listed exactly as the template grants them.

FeatureAccessPermissions added
Cost & Usage Report (always)Read-onlys3:GetObject and s3:ListBucket on the export bucket only; budgets:ViewBudget; organizations:ListAccounts; read-only Describe and List calls for EC2, Elastic IPs, snapshots, volumes, load balancers, RDS, ECS, ElastiCache, Redshift, DynamoDB and EMR; cloudwatch:GetMetricStatistics; iam:SimulatePrincipalPolicy.
Instance SchedulerWriteec2:StartInstances and ec2:StopInstances on instances; autoscaling:UpdateAutoScalingGroup on Auto Scaling groups.
Rightsizing recommendationsRead-onlycloudwatch:GetMetricData, cloudwatch:ListMetrics; compute-optimizer:GetEC2InstanceRecommendations, compute-optimizer:GetRDSDatabaseRecommendations.
Resource uptime monitoringRead-onlyec2:DescribeInstanceStatus; cloudwatch:DescribeAlarms, cloudwatch:GetMetricData; elasticloadbalancing:DescribeLoadBalancers, DescribeTargetGroups, DescribeTargetHealth.
Important
Instance Scheduler is the only feature that can change your environment, and only by starting or stopping instances and Auto Scaling groups. Leave it unticked for a strictly read-only role.

Organization stacks also create the member-account role CostGlassReadOnly in each member account with the read-only inventory permissions and the features you ticked.

Organization or single account?

AWS OrganizationRecommended for many accounts
Deploy once in the management account. A StackSet adds the member-account role to every account, now and in the future (automatic deployment is on by default). Needs StackSets trusted access.
Single account
One stack in one account. Choose this if the account is not in an Organization, or you only want to connect that one account.

The Organization template has two extra parameters you can change at deploy time: AutoDeployNewAccounts (default true) and RetainOnAccountRemoval (default false).

Example
A company has a management account and 12 member accounts. They choose AWS Organization, tick Rightsizing recommendations, and deploy once from the management account. They connect one thing in CostGlass, and all 13 accounts show up under it. A thirteenth member account created next month is picked up automatically.

Cost and Usage export: the 24 hour wait

The export is created as soon as the stack finishes, but AWS writes the first file in its own time, up to 24 hours later. Until then CostGlass is connected but has no data. From the dashboard you can use Fetch data now for a one-off pull from Cost Explorer; AWS charges $0.01 per request and the button states the cost before you confirm.

After the first delivery CostGlass reads new files every 6 hours.

Removing access

1
Disconnect in CostGlass
In Cloud Accounts remove the AWS connection (trash icon). CostGlass stops reading. For AWS this also deletes its discovered resources, anomalies, savings suggestions and older cost metrics for that connection; cost history already stored in the main cost tables is kept.
2
Delete the stack in AWS
Empty the S3 bucket first, otherwise CloudFormation cannot delete it. Then delete the stack. This removes the role, so CostGlass can no longer assume it. For an Organization, CloudFormation also removes the StackSet it created; if it reports the StackSet still has instances, delete those from CloudFormation → StackSets first.
Tip
Doing the AWS step alone also cuts off access immediately, because the role no longer exists.

Updating the stack later

  • Switch a feature off: update the stack and set its parameter to false (EnableInstanceScheduler, EnableRightsizing or EnableUptimeMonitoring).
  • Add a feature you did not tick: an unticked feature is not in the template at all, so a parameter cannot turn it on. The wizard builds templates for new connections; it does not offer a way to change the features of one that is already active. Contact CostGlass support for that.
  • When CostGlass adds new read-only checks it may need new permissions. Then redeploy the stack (or update the Organization StackSet). For example, the unused Elastic IP and idle load balancer checks need ec2:DescribeAddresses and elasticloadbalancing:Describe*. Until you do, that check finds nothing and says so on the Savings page.
Note
Your original feature choices are recorded when you verify and shown as small tags (Scheduler, Rightsizing, Uptime) on the account card. They are not changed by later stack updates.

Troubleshooting and FAQ

The stack fails with "Unrecognized resource types: [AWS::BCMDataExports::Export]".
You deployed in the wrong region. Delete the failed stack, switch the console to us-east-1 (N. Virginia) and create it again.
CloudFormation says it needs capabilities (InsufficientCapabilities).
Tick the acknowledgement that the stack creates IAM resources, or pass CAPABILITY_NAMED_IAM on the command line.
Verify says "Could not verify access to ... AccessDenied".
Check that the stack reached CREATE_COMPLETE, that the role ARN and bucket name were copied exactly, and that you deployed the template from this connection. If you started a second connection, its External ID differs from the first template's. Use the template shown for the pending connection.
Verify says the Role ARN does not look valid.
Paste the RoleArn output, which starts arn:aws:iam:: and contains :role/. Do not paste the stack ARN.
The Organization stack fails when creating the StackSet.
Trusted access is probably not enabled. In the management account open CloudFormation → StackSets and choose Enable trusted access with AWS Organizations, then retry.
The stack says the bucket or role already exists.
The bucket (costglass-cur-exports-<account ID>) and the role (CostGlassCURReader) have fixed names, so one AWS account can hold only one CostGlass stack. Delete the old stack first.
It says connected but I see no data.
Wait for AWS to deliver the first export, up to 24 hours, then click Check delivery now. Dashboard → Fetch data now gives you a quick one-off look in the meantime.
I get "You have reached your plan's connection limit".
Remove a connection you no longer need, finish or remove a pending one, or upgrade at Settings → Billing.
Can I deploy this without CloudFormation?

Related guides