hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.85k stars 9.2k forks source link

[Enhancement]: Support import of resources pending deletion #31468

Open geekofalltrades opened 1 year ago

geekofalltrades commented 1 year ago

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:

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)

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

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue