When registering a new handler package, and setting the lifecycle to created_before_destroy, and the old version is the default version for that type, terraform should assume that I'm also updating the default version of the type to the newly created version before destroying the old version/
aws cloudformation describe-type-registration > TypeVersionArn (gets new version ID)
aws cloudformation set-type-default-version new behavior, using new version ID
aws cloudformation deregister-type (old version ID)
Actual Behavior
After creating the updated version, terraform apply fails during the destroy operation with the following error:
Error: deregistering CloudFormation Type (arn:aws:cloudformation:REGION:ACCOUNTID:type/resource/my::custom::type/00000001): CFNRegistryException: Version '00000001' is the default version and cannot be deregistered. Deregister the resource type 'my::custom::type' instead.
status code: 400, request id: blah-blah-blah
aws cloudformation describe-type-registration > TypeVersionArn (gets new version ID)
aws cloudformation deregister-type (old version ID)
Relevant Error/Panic Output Snippet
Error: deregistering CloudFormation Type (arn:aws:cloudformation:REGION:ACCOUNTID:type/resource/my::custom::type/00000001): CFNRegistryException: Version '00000001' is the default version and cannot be deregistered. Deregister the resource type 'my::custom::type' instead.
status code: 400, request id: blah-blah-blah
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Terraform Core Version
1.5.7
AWS Provider Version
5.43.0
Affected Resource(s)
aws_cloudformation_type
Expected Behavior
When registering a new handler package, and setting the lifecycle to
created_before_destroy
, and the old version is the default version for that type, terraform should assume that I'm also updating the default version of the type to the newly created version before destroying the old version/Expected order of events:
Actual Behavior
After creating the updated version, terraform apply fails during the destroy operation with the following error:
It appears the current behavior is this:
Relevant Error/Panic Output Snippet
Terraform Configuration Files
First, apply a new CF type:
Then update with a different version:
Steps to Reproduce
deploy a
aws_cloudformation_type
and then update it with a new package.Debug Output
No response
Panic Output
No response
Important Factoids
Current workaround is to let the apply fail, then manually run the set-type-default-version command using the aws-cli, then re-apply terraform.
References
No response
Would you like to implement a fix?
Yes