aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

Waiter should accept UPDATE_COMPLETE and UPDATE_FAILED status when waiting for CloudFormation stack creation #633

Closed lturcsanyi closed 7 months ago

lturcsanyi commented 8 months ago

Describe the bug

The SDK uses the following class to wait for CF stack creation: software.amazon.awssdk.services.cloudformation.waiters.DefaultCloudFormationWaiter Generated from this file: https://github.com/aws/aws-sdk-java-v2/blob/04dffd75e4b045c913a6115628baa73f7cf6697e/services/cloudformation/src/main/resources/codegen-resources/waiters-2.json#L21

Currently, it checks for the following statuses: CREATE_COMPLETE, CREATE_FAILED, DELETE_COMPLETE, DELETE_FAILED, ROLLBACK_COMPLETE, ROLLBACK_FAILED.

The waiter polls the DescribeStack endpoint and checks for the statuses above. If something (e.g. an AWS lambda function automatically) modifies the newly created stack between two polling attempts, then the CloudFormation stack will be in UPDATE_COMPLETE status instead of CREATE_COMPLETE. This means that the waiter will never return successfully.

The waiter in the AWS SDK should check the UPDATE_COMPLETE and UPDATE_FAILED statuses as well.

Expected Behavior

The waiter in the AWS SDK should check the UPDATE_COMPLETE and UPDATE_FAILED statuses as well and return successfully even if something modifies the created CloudFormation stack.

Current Behavior

The CF stack was modified between two polling attempts, thus the CF stack was in UPDATE_COMPLETE status and the waiter never realized that the CF stack was created successfully.

Reproduction Steps

  1. create a CF stack
  2. wait for creation with CloudFormationWaiter:
  3. modify the created CF stack between two polling attempts (typically with some automation, e.g. aws lambda)

Possible Solution

The waiter in the AWS SDK should check the UPDATE_COMPLETE and UPDATE_FAILED statuses as well and return successfully even if something modifies the created CloudFormation stack.

Additional Information/Context

No response

AWS Java SDK version used

2.20.35

JDK version used

17

Operating System and version

N\A

debora-ito commented 8 months ago

Not sure if I agree that the stackCreateComplete waiter should account for update statuses, but in the end this is a decision that the service team must do. I'll raise this to the CloudFormation team, as they own the waiter model.

Moving this to the central aws/aws-sdk repo for visibility to other SDKs. I'll also change this to a feature request, as it's an improvement more than a bug.

pdarvasi commented 8 months ago

Not sure if I agree that the stackCreateComplete waiter should account for update statuses, but in the end this is a decision that the service team must do. I'll raise this to the CloudFormation team, as they own the waiter model.

Moving this to the central aws/aws-sdk repo for visibility to other SDKs. I'll also change this to a feature request, as it's an improvement more than a bug.

Thanks for your comment, but the waiter not recognizing CREATE_COMPLETE due to an update being made is definitely a bug and not a feature request.

lturcsanyi commented 8 months ago

Thanks for your comment, but the waiter not recognizing CREATE_COMPLETE due to an update being made is definitely a bug and not a feature request.

I agree. AWS also has features that allow automatic modification of CF stack, like AWS Lambda function, so its a valid scenario and I think the SDK should recognize such modifications.

debora-ito commented 8 months ago

If the CloudFormation team updates their waiter model, the change will be reflected in all SDKs.

I changed this to a feature request because right now the StackCreateComplete is working as expected. Recognizing the UPDATE statuses is an improvement on the current behavior.

Community note: if you are interested in this change, add a 👍 to the original description to help with prioritization.

P103984657

debora-ito commented 7 months ago

Good news, everyone!

CloudFormation is making the change. They are actively working on their waiter model to add "update" status to the StackCreateComplete, the change will be released in the near future.

debora-ito commented 7 months ago

The change was released.

Java SDK v2 2.21.38 includes the change. If you are using a different SDK, check their changelog for this entry:

AWS CloudFormation - 
    - Including UPDATE_* states as a success status for CreateStack waiter.
github-actions[bot] commented 7 months ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.