Enumerate all local CUR buckets in the auto-generated payer policy#103
Conversation
So a customer with multiple CURs in their payer account gets every CUR bucket granted to the CloudZero role, not just the one the discovery Lambda happened to pick as primary. Discovery now emits MasterPayerBillingBucketArns - a comma-separated ARN list (both bucket and bucket/* forms) covering every locally-owned CUR bucket. The master-payer template uses Fn::Split on it directly as the CZTier0BillingBucket20260420 statement's Resource list. The create-new-CUR path keeps emitting the new bucket pair (discovery is empty there by construction). MasterPayerBillingBucketName/Path keep their primary-bucket semantics for the notification flow. https://claude.ai/code/session_01KRtx6n6mePz1Bi5N8Me1FM
Note in the top-level README that the auto-generated role grants
s3:Get*/s3:List* on every CUR bucket discovered in the account, and add
a section to policies/README.md explaining that the canonical single
{{BillingBucketName}} ARN pair is expanded at deploy time.
https://claude.ai/code/session_01KRtx6n6mePz1Bi5N8Me1FM
Covers the mixed-local/remote case: prior tests covered all-local and all-remote, but not a payer with both. Verifies get_all_local_cur_bucket_names keeps the two local CUR buckets and drops the one whose report references a non-local (remote-account-owned) bucket. Commit Generated with AI Co-Authored-By: AI
|
@greptile |
|
@greptile |
Greptile SummaryThis PR extends the Discovery Lambda to enumerate all locally-owned CUR buckets (not just the schema-valid primary) and threads that comma-separated ARN list through to the master-payer IAM policy, so a payer account with multiple CUR reports gets
Confidence Score: 5/5The change is safe to merge — all three issues raised in the previous review round have been addressed, and the new code paths are covered by targeted unit tests. The No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "codeql not working, github outage need t..." | Re-trigger Greptile |
Summary
MasterPayerBillingBucketArns— a comma-separated ARN list (bothbucketandbucket/*forms) covering every locally-owned CUR bucket it found, not just the one chosen as primary.master_payer.yamlusesFn::Spliton that string directly as theCZTier0BillingBucket20260420Resource:list, so a payer account with multiple CURs gets every CUR bucket granted to the CloudZero role.MasterPayerBillingBucketName/Pathkeep their primary-bucket semantics for the notification flow.Files touched
services/discovery/src/app.py— newget_all_local_cur_bucket_names+format_bucket_arns; new output key inDEFAULT_OUTPUTandOUTPUT_SCHEMA.services/discovery/template.yaml— new outputMasterPayerBillingBucketArns.services/connected_account.yaml,services/connected_account_dev.yaml— pass the new output as a parameter to the master-payer nested stack.services/account_type/master_payer.yaml— newMasterPayerBillingBucketArnsparameter;CZTier0BillingBucket20260420Resource:becomes!Splitover the ARN list (or the single new-bucket pair when creating a CUR).services/discovery/tests/unit/test_app.py— updated full-output assertions + new multi-CUR enumeration test.Test plan
python -m pytest services/discovery/tests/unit/test_app.py— 13 passed (12 existing + 1 new).cfn-linton all four touched templates — only the pre-existingIsOrganizationMasterAccount not usedwarning.cz-cur-hourly-csv-${StackId}bucket pair.https://claude.ai/code/session_01KRtx6n6mePz1Bi5N8Me1FM
Generated by Claude Code