fix(provisioning): retry KMS fresh-principal policy + bind EC2 IAM instance profile post-launch - #848
Merged
Merged
Conversation
…instance profile post-launch Harden two propagation-race paths surfaced by the propagation-races-2 fixture: - retryable-errors: classify KMS key-policy "fresh principal" failures as retryable so a just-created IAM principal referenced in a KMS key policy is retried until IAM propagation catches up. - ec2-provider: after launching an EC2 instance, describe-then-associate the IAM instance profile and poll until the association is observed, so a freshly created instance profile binds reliably despite IAM propagation lag. Adds the propagation-races-2 integration fixture plus unit coverage for the KMS retry classifier and the EC2 instance-profile bind path.
go-to-k
force-pushed
the
test/propagation-races-2
branch
from
June 14, 2026 01:27
cc81631 to
c7bddab
Compare
Owner
Author
|
Independent code review complete (pr-code-reviewer): both fixes clean, no blockers. KMS + IAM-instance-profile retry patterns well-anchored; normalizeIamInstanceProfile handles all 3 shapes; post-launch describe-associate-poll is bounded (10 attempts each), idempotent, and correctly treats 'associating' as not-yet-bound. 3 minor nits accepted as known cost: a dead defensive branch (ec2-provider.ts:2521), worst-case ~90s propagation wall-time (within the per-resource path), and a slightly-broad 'not authorized' substring (bounded by maxAttempts). Plus unit tests + real-AWS integ PASS. Setting pr-review bound to c7bddab. |
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 14, 2026
## [0.221.8](v0.221.7...v0.221.8) (2026-06-14) ### Bug Fixes * **provisioning:** retry KMS fresh-principal policy + bind EC2 IAM instance profile post-launch ([#848](#848)) ([afd5c63](afd5c63))
|
🎉 This PR is included in version 0.221.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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 branch fixes two real cdkd bugs that surface when a resource consumes a freshly-created IAM principal/profile, plus adds the
propagation-races-2integ fixture and unit tests.Bug 1: KMS Key create fails on fresh-IAM-principal key policy (propagation race)
Creating a KMS Key whose key policy references a just-created IAM principal failed with
Policy contains a statement with one or more invalid principals. The IAM principal exists but has not yet propagated to the region KMS validates against, so the firstCreateKeyis rejected.Fix: added the fresh-principal propagation pattern to
src/deployment/retryable-errors.tsso the create is retried until the principal is visible to KMS.Bug 2: EC2 instance silently launches without its fresh IAM instance profile
IamInstanceProfilein the template is a NAME string, not a{Arn, Name}object. The prior code passed the raw value through in a shape the SDK ignored, so the instance launched with no instance profile bound and no error was raised.Fix in
src/provisioning/providers/ec2-provider.ts:IamInstanceProfileshape (accept a name string),Tests
propagation-races-2integ fixture (4 fresh-principal/consumer race edges) withverify.sh.tests/unit/deployment/retryable-errors.test.ts(KMS fresh-principal retry classification) andtests/unit/provisioning/providers/ec2-provider-instance-profile-bind.test.ts(shape normalization + post-launch associate/poll).Verification
Validated green against real AWS (deploy + destroy clean) on the
propagation-races-2fixture.