Currently certain AWS resources are not fully deleted when destroyed, but are instead scheduled for deletion. These resources cannot be reimported into the Terraform state until they have been manually undeleted outside of Terraform.
This is already annoying, but with the addition of import blocks in Terraform 1.5.0, it will break declarative code. The following code cannot be applied, destroyed, and then applied again in Terraform 1.5.0-beta1:
resource "aws_secretsmanager_secret" "test" {
name = "test"
}
import {
# Doesn't actually need to be a full ARN to be imported successfully, in spite of documentation.
# This resource type gets some random characters added to the end of its ARN by AWS.
id = "arn:aws:secretsmanager:us-west-2:xxx:secret:test"
to = aws_secretsmanager_secret.test
}
$ terraform plan
aws_secretsmanager_secret.test: Preparing import... [id=arn:aws:secretsmanager:us-west-2:xxx:secret:test]
aws_secretsmanager_secret.test: Refreshing state... [id=arn:aws:secretsmanager:us-west-2:xxx:secret:test]
Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: reading Secrets Manager Secret (arn:aws:secretsmanager:us-west-2:xxx:secret:test): couldn't find resource
│
│
╵
Resources with this property should have their import enhanced to restore them if they are pending deletion.
Affected Resource(s) and/or Data Source(s)
aws_secretsmanager_secret
aws_kms_key
Possibly others that follow the pattern of pending deletion before being fully removed.
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.
Description
Currently certain AWS resources are not fully deleted when destroyed, but are instead scheduled for deletion. These resources cannot be reimported into the Terraform state until they have been manually undeleted outside of Terraform.
This is already annoying, but with the addition of
import
blocks in Terraform 1.5.0, it will break declarative code. The following code cannot be applied, destroyed, and then applied again in Terraform 1.5.0-beta1:Resources with this property should have their import enhanced to restore them if they are pending deletion.
Affected Resource(s) and/or Data Source(s)
aws_secretsmanager_secret
aws_kms_key
Possibly others that follow the pattern of pending deletion before being fully removed.
Potential Terraform Configuration
No response
References
No response
Would you like to implement a fix?
None