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

Resource aws_ami doesn't support import #4907

Closed
finferflu opened this issue Jun 21, 2018 · 10 comments · Fixed by #5990
Closed

Resource aws_ami doesn't support import #4907

finferflu opened this issue Jun 21, 2018 · 10 comments · Fixed by #5990
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@finferflu
Copy link
Contributor

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 "me too" comments, 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

Description

The AWS provider currently doesn't support importing aws_ami resources.

New or Affected Resource(s)

  • aws_ami (Terraform v0.11.7, provider.aws v1.24.0)
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jun 21, 2018
@tomelliff
Copy link
Contributor

Why would you want to import an AMI for Terraform to manage? If you want to be able to refer to an AMI you should be able to use the aws_ami data source.

The aws_instance resource docs give a good example of this:

data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

resource "aws_instance" "web" {
  ami           = "${data.aws_ami.ubuntu.id}"
  instance_type = "t2.micro"

  tags {
    Name = "HelloWorld"
  }
}

@finferflu
Copy link
Contributor Author

@tomelliff, thanks for getting back to me. I am using Packer to generate AMIs, which means that they stay unmanaged. I would have liked to import them via Terraform so that they could be appropriately destroyed/recreated as needed, and for that reason using a data source doesn't help. I hope that makes sense.

Thank you!

@mchouque
Copy link

I have the same exact need, as in I want to import my own image. Right now I convert them using aws ec2 import-image.

@bflad
Copy link
Contributor

bflad commented Sep 26, 2018

Pull request submitted: #5990

@mchouque
Copy link

So if my understanding is correct, this pull request would solve the initial problem but wouldn't solve the step of creating an AMI from a disk image contained in a S3 bucket, right?

@bflad
Copy link
Contributor

bflad commented Sep 26, 2018

@mchouque you are correct. Could you submit a new, separate feature request issue with details about your use case and potential configuration? I bet a fresh issue would garner more attention than this existing issue since it might be slightly confusing with both Terraform and EC2 have differing meanings for "import". 😄

@bflad bflad added this to the v1.38.0 milestone Sep 26, 2018
@mchouque
Copy link

@bflad Thanks for the feedback, I created #5998 about that.

@bflad
Copy link
Contributor

bflad commented Sep 26, 2018

@mchouque great write up! 💯

@bflad
Copy link
Contributor

bflad commented Sep 26, 2018

This has been released in version 1.38.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 3, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants