Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit e99a8b5

Browse files
committed
Detect changeset creation failure when there's no changet
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 4b88896 commit e99a8b5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ecs/sdk.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,20 @@ func (s sdk) CreateChangeSet(ctx context.Context, name string, template []byte)
264264
return "", err
265265
}
266266

267-
err = s.CF.WaitUntilChangeSetCreateCompleteWithContext(ctx, &cloudformation.DescribeChangeSetInput{
267+
// we have to WaitUntilChangeSetCreateComplete even this in fail with error `ResourceNotReady`
268+
// so that we can invoke DescribeChangeSet to check status, and then we can know about the actual creation failure cause.
269+
s.CF.WaitUntilChangeSetCreateCompleteWithContext(ctx, &cloudformation.DescribeChangeSetInput{ // nolint:errcheck
268270
ChangeSetName: changeset.Id,
269271
})
272+
273+
desc, err := s.CF.DescribeChangeSetWithContext(ctx, &cloudformation.DescribeChangeSetInput{
274+
ChangeSetName: aws.String(update),
275+
StackName: aws.String(name),
276+
})
277+
if aws.StringValue(desc.Status) == "FAILED" {
278+
return *changeset.Id, fmt.Errorf(aws.StringValue(desc.StatusReason))
279+
}
280+
270281
return *changeset.Id, err
271282
}
272283

0 commit comments

Comments
 (0)