fix: resolve asset staging timing issue and use dynamic region for multi-region StackSets#881
Open
spensireli wants to merge 1 commit into
Open
fix: resolve asset staging timing issue and use dynamic region for multi-region StackSets#881spensireli wants to merge 1 commit into
spensireli wants to merge 1 commit into
Conversation
cdklabs-automation
enabled auto-merge
January 22, 2026 18:38
Replace hardcoded 'arn:aws:' / 'amazonaws.com' with Stack.formatArn and
Stack.urlSuffix so self-managed StackSets resolve the correct partition
(e.g. aws-us-gov) at deployment time.
Also fix asset staging in StackSetStackSynthesizer: delegate staging to
the parent stack's synthesizer and reference the staged object via
Source.bucket() instead of Source.asset() on a not-yet-existing local
path, and derive the per-region asset bucket name from Fn.ref('AWS::Region')
so it resolves in each target region at deploy time.
Add aws-us-gov to the integ test target-partitions, regenerate the integ
snapshot, and add unit tests covering the partition-aware ARN / URL suffix.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
auto-merge was automatically disabled
July 23, 2026 23:58
Head branch was pushed to by a user without write access
This was referenced Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two issues with the
StackSetStackSynthesizerthat prevent proper multi-region StackSet deployments with assets (e.g., Lambda functions):1. Asset Staging Timing Issue
The
addFileAssetmethod was usingSource.asset()with a local file path that doesn't exist during synthesis. This fix delegates asset staging to the parent stack's synthesizer first, then usesSource.bucket()to reference the staged asset in S3.Changes:
parentStack.synthesizer.addFileAsset(asset)Bucket.fromBucketName()Source.bucket()to reference the asset from S3 instead of local file pathProductStackSynthesizerin aws-cdk-lib2. Dynamic Region Reference for Multi-Region Deployments
The bucket name was being constructed using
this.boundStack.regionwhich hardcodes the parent stack's region at synthesis time. For multi-region StackSets, each target region needs to resolve thebucket name dynamically.
Changes:
Fn.join('-', [this.assetBucketPrefix, this.boundStack.region])Fn.join('-', [this.assetBucketPrefix, Fn.ref('AWS::Region')])How It Works
When deploying StackSets with Lambda functions or other assets across multiple regions:
BucketDeploymentcopies assets to regional buckets (e.g.,my-assets-us-east-1,my-assets-us-west-2)${AWS::Region}intrinsic so each target region fetches from its local bucketTest Plan