Update your AWS connection

Update your AWS connection when CloudZero publishes new permission templates or when AWS changes its billing and cost management permissions. Keeping permissions up to date ensures CloudZero has access to the latest cost and resource data needed for accurate recommendations and new features. You control the permissions you grant CloudZero, and connections do not update themselves.

CloudZero publishes all AWS Identity and Access Management (IAM) policies and CloudFormation templates as open source in the provision-account repository. The sections below use those published templates.

Automated connections

If you connected using the automated method, update the CloudZero CloudFormation stack. The stack is named cloudzero-connected-account for a Billing (Payer) account and cloudzero-connected-member-resource-account for a Resources (Member) account. Choose either the AWS Console or the AWS CLI.

Option A: Update the stack in the AWS Console

  1. Open the AWS CloudFormation console in the AWS account where the stack is deployed.
  2. Find the CloudZero stack. If you do not see it, uncheck View Nested and search for cloudzero.
  3. Select Update.
  4. Select Replace current template.
  5. Paste the following URL into the Amazon S3 URL field:
https://cz-provision-account.s3.amazonaws.com/latest/services/connected_account.yaml
  1. Select Next three times to reach the review page.
  2. Check both boxes in the Capabilities section:
    • I acknowledge that AWS CloudFormation might create IAM resources with custom names.
    • I acknowledge that AWS CloudFormation might require the following capability: CAPABILITY_AUTO_EXPAND
  3. Select Submit.

Option B: Update the stack with the AWS CLI

The following command updates the stack while preserving your existing parameters. It requires the AWS CLI and the jq package. For a Resources (Member) account, replace cloudzero-connected-account with cloudzero-connected-member-resource-account in the --stack-name value and in the describe-stacks command.

aws cloudformation update-stack \
  --stack-name cloudzero-connected-account \
  --template-url https://cz-provision-account.s3.amazonaws.com/latest/services/connected_account.yaml \
  --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
  --parameters "$(aws cloudformation describe-stacks --stack-name cloudzero-connected-account | jq '.Stacks[0].Parameters')"

Manual connections

If you connected using the manual method, update the IAM role's trust policy, inline policy, and managed policies. Choose either the AWS Console or the AWS CLI.

⚠️

Manual connections must update the trust policy, the inline policy, and the managed policies. The trust policy must include two CloudZero account IDs: 061190967865 and 559846027439. Automated connections pick this up automatically when you update the stack.

Option A: Update the role in the AWS Console

  1. Open the AWS IAM console in the AWS account where the role is deployed.
  2. Search for cloudzero in the Roles list. Select the role with Trusted entities containing Account: 061190967865.
  3. On the Trust relationships tab, select Edit trust policy.
  4. In the Principal section, make sure both CloudZero account IDs are listed. Keep your existing sts:ExternalId condition unchanged:
"Principal": {
  "AWS": [
    "arn:aws:iam::061190967865:root",
    "arn:aws:iam::559846027439:root"
  ]
}
  1. Select Update policy.
  2. On the Permissions tab, select the attached Customer inline policy.
  3. Select the JSON tab.
  4. Replace the policy content with the latest version for your account type:
  5. For a Billing (Payer) account, replace both instances of {{BillingBucketName}} in the policy with the name of the S3 bucket that receives your billing data. CloudZero needs the bucket name to read it.
  6. Select Review policy.
  7. Select Save changes.
  8. On the Permissions tab, select Add permissions > Attach Policies.
  9. Select each of these AWS managed policies that the role doesn't already have: ComputeOptimizerReadOnlyAccess, ViewOnlyAccess, and AWSBillingReadOnlyAccess.
  10. Select Add permissions.

Option B: Update the role with the AWS CLI

These commands require the AWS CLI and the jq package.

  1. Find your role name, policy name, and External ID:
aws iam list-roles | jq -r '.Roles[] | select(.AssumeRolePolicyDocument | tostring | contains("061190967865")) | .RoleName'
aws iam list-role-policies --role-name <role-name> | jq -r -e '.PolicyNames[]'
aws iam get-role --role-name <role-name> | jq -r '.Role.AssumeRolePolicyDocument.Statement[0].Condition.StringEquals."sts:ExternalId"'
  1. Replace the placeholders in the block below:
PlaceholderValue
<role-name>The role name from step 1
<policy-name>The inline policy name from step 1
<external-id>The External ID from step 1
<policy-url>Billing (Payer): https://cz-provision-account.s3.amazonaws.com/latest/policies/master_payer.json
Resources (Member): https://cz-provision-account.s3.amazonaws.com/latest/policies/resource_owner.json
<bucket-name>Billing (Payer): the name of the S3 bucket that receives your billing data
Resources (Member): no change needed
aws iam update-assume-role-policy \
  --role-name <role-name> \
  --policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": { "AWS": ["arn:aws:iam::061190967865:root", "arn:aws:iam::559846027439:root"] },
        "Action": "sts:AssumeRole",
        "Condition": { "StringEquals": { "sts:ExternalId": "<external-id>" } }
      }
    ]
  }'

aws iam put-role-policy \
  --role-name <role-name> \
  --policy-name <policy-name> \
  --policy-document "$(curl -s <policy-url> | sed 's/{{BillingBucketName}}/<bucket-name>/g')"

for policy in ComputeOptimizerReadOnlyAccess job-function/ViewOnlyAccess AWSBillingReadOnlyAccess; do
  aws iam attach-role-policy \
    --role-name <role-name> \
    --policy-arn "arn:aws:iam::aws:policy/$policy"
done
  1. Run the block in your terminal.

What to expect

New permissions take effect once the changes are saved. No reconnection is needed in CloudZero. You can verify the connection health on the Connections page in Settings.

For details on what each permission grants, see AWS permissions and security.

ℹ️

Have questions or feedback? Reach out to your account manager.


Did this page help you?