Terraform-provider-aws: Not able to import aws_volume_attachment using the command provided in terraform documentation

Created on 28 Apr 2020  ·  8Comments  ·  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @aykarageorge as hashicorp/terraform#24790. It was migrated here as a result of the provider split. The original body of the issue is below._


I have an EC2, EBS volume, and volume_attachment resources managed by terraform. After deploying it, I removed the EBS volume from EC2 and attached a new EBS volume manually from AWS console. Later I did terraform refresh and terraform import for the new EBS volume, which updated my tfstate with the new volume. But when I tried to import the aws_volume_attachment it throws the following error.

**Error:** resource aws_volume_attachment doesn't support import

I'm using terraform version 0.12.24
error

All 8 comments

@aykarageorge

You can import the instance and the volume. Then perform an apply. Even though it thinks the attachment is a new resource to create, it will just work. I performed this using provider 2.53. I was in a similar situation to you. I found the documentation and tried to import like it said and I received the same error message you did. Since my instance and volume were not production, I just took a shot on allowing Terraform to 'create' it again and it worked.

I just think the documentation needs to be updated.

@danielshiplet

Thank you for the response. The thing is, I cannot have a recreation. Also this is in production. My instance is fine, but ebs volume recreates. So this will destroy and recreate the existing volume.
Actually I'm trying to achive a failover scenario, where I manually detach and attach the ebs volume to another instance. Then trying to import the ebs volume to tfstate.

Any updates?

hi @aykarageorge! thank you for submitting this issue. which version of the provider are you using in your configs? import support was added in the v2.59.0 release

I too encountered this with:

$ terraform -v
Terraform v0.12.24
+ provider.aws v2.53.0
+ provider.template v2.1.2

Upgrading my AWS provider to v2.60.0 resolved the issue I retried the command and it worked fine. Thank you @anGie44 for pointing that out.

$ terraform -v
Terraform v0.12.24
+ provider.aws v2.60.0
+ provider.template v2.1.2

Aside, I really wish the docs (in general) would indicate the version something was added (ala Python style). But that's a more general issue with the terraform docs.

@dekimsey To view version specific documentation (which will be made the default in the coming months), you can browse the Terraform Registry documentation. See also the HashiCorp Blog Announcement. 👍

Thank you @anGie44 @dekimsey. Setting the AWS provider version to 12.60 solved the problem.

provider "aws" {
  version = "2.62.0"
}

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings