Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_volume_attachment complains about "VolumeInUse" from imported resources #8458

Closed
nicocesar opened this issue Aug 24, 2016 · 9 comments
Closed

Comments

@nicocesar
Copy link

Terraform Version

Terraform v0.7.1

Affected Resource(s)

aws_volume_attachment

TF files

https://gist.github.com/nicocesar/378565e259cc5e5ae6076b571344f377

Debug Output

https://gist.github.com/nicocesar/5e2e8f9c9290179b1fb0a61509cf30e8

Expected Behavior

I've imported the volume and the instace using terraform import. But I don't know how to import the aws_volume_attachment. When I execute the terraform apply it tries to attach an already attached volume.

I just want to: a) do not report a missing attachment or b) know how to use terraform import to add this information too.

Steps to Reproduce

  1. terraform import aws_instance.shell i-afe8972f
  2. terraform import aws_ebs_volume.shell_data vol-fbaa2524
  3. terraform apply
@tdeheurles
Copy link

Hi,
Our 2 issues seems close: #9910

Have you found a solution to this problem ? To me, we need to import the aws_volume_attachment but I don't know how to find it through aws.

@tdeheurles
Copy link

If it can help someone, I manually updated the aws_volume_attachment in the terraform state to match the new requirements. It seems that this aws_volume_attachment_id doesn't exist in amazon but only for terraform

@nicocesar
Copy link
Author

Can you provide a diff of your "manual update"?

On Mon, Nov 7, 2016, 07:55 thibault deheurles notifications@github.com
wrote:

If it can help someone, I manually updated the aws_volume_attachment in
the terraform state to match the new requirements. It seems that this
aws_volume_attachment_id doesn't exist in amazon but only for terraform


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#8458 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZ8eS55F7ulVGoKD6o5RzF367qKT0tpks5q7x-0gaJpZM4JsXzN
.

@tdeheurles
Copy link

Here is the part of the json for the aws_volume_attachment :

"aws_volume_attachment.name": {
    "type": "aws_volume_attachment",
    "depends_on": [
        "aws_ebs_volume.name",
        "aws_instance.name"
    ],
    "primary": {
        "id": "vai-1501514762",
        "attributes": {
            "device_name": "xvdh",
            "id": "vai-1501514762",
            "instance_id": "i-0df597a608df3c6fb",
            "volume_id": "vol-d4398402"
        },
        "meta": {},
        "tainted": false
    },
    "deposed": [],
    "provider": ""
}

So I have just updated :

  • aws_volume_attachment.name.primary.attributes.instance_id
  • aws_volume_attachment.name.primary.attributes.volume_id
    to match the new resources.

Note that these 2 resources were imported with terraform import before.

@tdna
Copy link

tdna commented Dec 16, 2016

I have the same problem. Where does this id come from?

@foxsy
Copy link

foxsy commented Jan 5, 2017

This ID is generated when Terraform writes the attachment to the state file. I had the same issue when I imported some resources and had to modify the state file by hand. Since you can't use "terraform import" on a volume attachment your options are limited. You can either force detach and let Terraform attach the volume, or you can manually update the state file and regenerate the "vai" ID. To make this easier I pulled the relevant code that generates that ID and put it on github. https://github.com/foxsy/tfvolattid

@nicocesar
Copy link
Author

Thanks for the relevant information, @foxsy but why can't terraform just do that for you upon import? is there anything I'm missing here? by the time you do terraform import aws_ebs_volume.shell_data vol-fbaa2524 (look in my example) can't it ask you for a mount point or some extra info to make this happen without manual interventions... I have pending to migrate to terraform many clusters, I don't want to do manually all this conversions

@stack72
Copy link
Contributor

stack72 commented Feb 1, 2017

Closed via #11060

@ghost
Copy link

ghost commented Apr 17, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants