terraform-provider-aws: Using the aws_serverlessapplicationrepository_cloudformation_stack resource works the first time, but subsequent updates fail.
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- 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
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform CLI and Terraform AWS Provider Version
Terraform v0.13.5
Affected Resource(s)
aws_serverlessapplicationrepository_cloudformation_stack
Terraform Configuration Files
data aws_serverlessapplicationrepository_application directory_app {
application_id = var.app_id
semantic_version = var.app_semver
}
resource aws_serverlessapplicationrepository_cloudformation_stack directory_index_stack {
count = var.disabled || ! var.enable_default_directory_index ? 0 : 1
name = "${var.stack_name}-${var.stage}-directory-index"
tags = var.tags
application_id = data.aws_serverlessapplicationrepository_application.directory_app.application_id
capabilities = data.aws_serverlessapplicationrepository_application.directory_app.required_capabilities
parameters = {
Version = var.version
}
}
Expected Behavior
Running 2 times should not cause an error.
Actual Behavior
Doing a terraform apply the second time results in an error: Error: error creating Serverless Application Repository CloudFormation Stack (arn:aws:cloudformation:::stack/<stack_name>/) change set: unexpected state ‘FAILED’, wanted target ‘CREATE_COMPLETE’. last error: %!s()
Looking in cloudformation, the change set is Status: Failed, Status Reason: No updates are to be performed.
Steps to Reproduce
terraform apply
(my example is using Lambda at edge functions if this makes a difference)terraform apply
a second time
Important Factoids
References
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 60
- Comments: 20 (5 by maintainers)
Commits related to this issue
- service/serverlessapplicationrepository: Add issue and pull request labeling Reference: https://github.com/hashicorp/terraform-provider-aws/issues/16485 — committed to hashicorp/terraform-provider-aws by bflad 4 years ago
- service/serverlessapplicationrepository: Add issue and pull request labeling (#16486) Reference: https://github.com/hashicorp/terraform-provider-aws/issues/16485 — committed to hashicorp/terraform-provider-aws by bflad 4 years ago
I can confirm that this problem still exists in the latest version of the provider even after almost 2 year. As @cdhesse said, if you have more than 4 parameters, somehow the plan only refreshes up to 4 parameters from current stack that exists in AWS, and the rest of the parameters are treated as new, hence a diff is calculated. But when you apply the plan, since the diff that was calculated is not the reality, apply errors out with
change set: unexpected state 'FAILED', wanted target 'CREATE_COMPLETE'. last error: No updates are to be performed
errorAlso seeing this issue.
We’ve deployed a stack using
which creates a cloudformation stack called serverlessrepo-salesforceIntegrationLambda.
However, on the second
terraform apply
, we get a failure. Checking CloudTrail, I can see that acloudformation.DescribeStacks
API call is failing with the errorStack with id aws-serverless-repository-salesforceIntegrationLambda does not exist
- it seems to be looking for the wrong stack name?My temporary solution for this was to add a tag with a random string. this forces an update on every apply though, so it’s not ideal.
My work around to this issue. just use the local .json or .yml CloudFormation template with terraform
aws_cloudformationn_stack
resource. Thenterraform apply
works fine without destroying the CloudFormation stack resource.