fix(cloudformation): record REVIEW_IN_PROGRESS event on change-set creation (#1431)

* fix(cloudformation): record REVIEW_IN_PROGRESS event on change-set creation

A CREATE change set puts a brand-new stack into REVIEW_IN_PROGRESS, but
createChangeSet recorded no stack event, so DescribeStackEvents returned an
empty list for it. AWS and LocalStack return at least the REVIEW_IN_PROGRESS
stack event; tooling that reads StackEvents[0] right after change-set creation
(e.g. the AWS SAM CLI's get_last_event_time) therefore fails on floci with
"list index out of range" before any resources are deployed.

Record the REVIEW_IN_PROGRESS stack-level event when a CREATE change set
creates a new stack, scoped to that path (nested stacks and update change sets
are unaffected). Adds an integration test.

Fixes #1429

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Vishal Goyal <vishal.goyal@home24.de>

* fix(cloudformation): address review — atomic new-stack detection + CREATE gate

Detect first stack creation via the computeIfAbsent mapping function (runs at
most once per key, so it's atomic and won't double-record the event under
concurrent CreateChangeSet calls) instead of a non-atomic containsKey pre-check,
and only record the REVIEW_IN_PROGRESS event for CREATE-type change sets
(null defaults to CREATE, matching createChangeSet).
This commit is contained in:
Vishal Goyal authored and GitHub committed 2026-06-18 18:45:53 -05:00
1 parent 56706217d3
commit 9bb1db3a54
2 files changed
+57

No files matched your search

@@ -1012,6 +1012,48 @@ class CloudFormationIntegrationTest {
.body(containsString("<StackName>arn-events-stack</StackName>"));
}
@Test
void createChangeSet_recordsReviewInProgressEvent() {
// A CREATE change set for a brand-new stack must record a REVIEW_IN_PROGRESS stack event,
// so DescribeStackEvents is non-empty right after CreateChangeSet (matching AWS/LocalStack).
// Tooling such as the AWS SAM CLI reads StackEvents[0] at this point.
String template = """
{
"Resources": {
"MyBucket": {
"Type": "AWS::S3::Bucket",
"Properties": { "BucketName": "review-event-bucket" }
}
}
}
""";
given()
.contentType("application/x-www-form-urlencoded")
.formParam("Action", "CreateChangeSet")
.formParam("StackName", "review-event-stack")
.formParam("ChangeSetName", "cs1")
.formParam("ChangeSetType", "CREATE")
.formParam("TemplateBody", template)
.when()
.post("/")
.then()
.statusCode(200);
// Before the change set is executed the stack is REVIEW_IN_PROGRESS and must already
// carry a matching stack-level event.
given()
.contentType("application/x-www-form-urlencoded")
.formParam("Action", "DescribeStackEvents")
.formParam("StackName", "review-event-stack")
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("<ResourceType>AWS::CloudFormation::Stack</ResourceType>"))
.body(containsString("<ResourceStatus>REVIEW_IN_PROGRESS</ResourceStatus>"));
}
@Test
void describeDeletedStackEvents_byArn_returnsDeleteCompleteEvents() throws Exception {
String template = """