I haven’t decided whether I think this is a feature or a bug or whether it is just the way cloudformation works. If others think it is a bug then I will file one, otherwise this is here for reference. So here is the scenario:
- We changed the path of a previously deploy (but unused) resource
- Once the change was deployed the gateway method was replaced but the old and the new resource were present in the deployed stage
- Reviewing the cloudformation events showed that the old resource was only deleted after the new deployment was complete
- Thus it appears that it was included since it will still present when the new deployment was created
- This hypothesis seems to be confirmed because when we ran the template again, this 2nd time the old resource was removed from the stage
I don’t think that cloudformation is doing this for backwards compatibility. That should be our responsibility.
Maybe cloudformation is treating this like any other delete in that it leaves them until the end for rollback purposes.
The template generated by serverless does have all the necessary dependencies defined.
There is a workaround, so this is not a critical issue. Plus resources are not changed and/or deleted frequently.
Does anyone have any insights on this topic?
Here are the mentioned CF events:
CloudFormation - CREATE_COMPLETE - AWS::ApiGateway::Deployment - ApiGatewayDeployment1499362775092
CloudFormation - UPDATE_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - xyz-service-dev
CloudFormation - DELETE_COMPLETE - AWS::Lambda::Version - XyzLambdaVersionCoFFbzoKa0FlERF5uyjKpO3Sh8SdSMMuFCNLdW6o
CloudFormation - DELETE_IN_PROGRESS - AWS::ApiGateway::Deployment - ApiGatewayDeployment1499361487191
CloudFormation - DELETE_COMPLETE - AWS::ApiGateway::Deployment - ApiGatewayDeployment1499361487191
CloudFormation - DELETE_IN_PROGRESS - AWS::ApiGateway::Method - ApiGatewayMethodXyzPost
CloudFormation - DELETE_COMPLETE - AWS::ApiGateway::Method - ApiGatewayMethodXyzPost
CloudFormation - DELETE_IN_PROGRESS - AWS::ApiGateway::Resource - ApiGatewayResourceXyz
CloudFormation - DELETE_COMPLETE - AWS::ApiGateway::Resource - ApiGatewayResourceXyz
CloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - xyz-service-dev