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

Unable to create an aws_launch_configuration with an instance store AMI #8732

Closed
omribahumi opened this issue Sep 8, 2016 · 8 comments · Fixed by #9483
Closed

Unable to create an aws_launch_configuration with an instance store AMI #8732

omribahumi opened this issue Sep 8, 2016 · 8 comments · Fixed by #9483

Comments

@omribahumi
Copy link

omribahumi commented Sep 8, 2016

Terraform Version

$ terraform --version
Terraform v0.7.3

Affected Resource(s)

  • aws_launch_configuration

Terraform Configuration Files

provider "aws" {
  region = "us-east-1"
}

resource "aws_launch_configuration" "test-launch-config" {
  image_id = "ami-01f69916" // us-east-1 ubuntu 12.04 amd64 hvm instance-store
  instance_type = "c3.large"
}

Debug Output

$ terraform apply
aws_launch_configuration.test-launch-config: Creating...
  associate_public_ip_address: "" => "false"
  ebs_block_device.#:          "" => "<computed>"
  ebs_optimized:               "" => "<computed>"
  enable_monitoring:           "" => "true"
  image_id:                    "" => "ami-01f69916"
  instance_type:               "" => "c3.large"
  key_name:                    "" => "<computed>"
  name:                        "" => "<computed>"
  root_block_device.#:         "" => "<computed>"
Error applying plan:

1 error(s) occurred:

* aws_launch_configuration.test-launch-config: [WARN] Error finding Root Device Name for AMI (ami-01f69916)

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

Launch config should have been created.
When using the same AMI without block devices on a aws_instance resource, everything works fine.

Actual Behavior

Fails with an error:
Error finding Root Device Name for AMI (ami-01f69916)

Steps to Reproduce

terraform apply

@jbussdieker
Copy link

Has anyone found a workaround for this yet?

@tpounds
Copy link
Contributor

tpounds commented Sep 27, 2016

We are experiencing the same issue. This behavior change was introduced by commit 391a7f8 and affects all Terraform versions >= v0.7.x.

@tpounds
Copy link
Contributor

tpounds commented Sep 27, 2016

The problem is due to the code not understanding that some AMIs root devices are backed by the instance store. Compare the output from the official Amazon Linux AMIs

$ aws ec2 describe-images --region us-east-1 --image-ids ami-6869aa05
{
    "Images": [
        {
            "VirtualizationType": "hvm", 
            "Name": "amzn-ami-hvm-2016.03.3.x86_64-gp2", 
            "Hypervisor": "xen", 
            "ImageOwnerAlias": "amazon", 
            "SriovNetSupport": "simple", 
            "ImageId": "ami-6869aa05", 
            "State": "available", 
            "BlockDeviceMappings": [
                {
                    "DeviceName": "/dev/xvda", 
                    "Ebs": {
                        "DeleteOnTermination": true, 
                        "SnapshotId": "snap-25dd2ac1", 
                        "VolumeSize": 8, 
                        "VolumeType": "gp2", 
                        "Encrypted": false
                    }
                }
            ], 
            "Architecture": "x86_64", 
            "ImageLocation": "amazon/amzn-ami-hvm-2016.03.3.x86_64-gp2", 
            "RootDeviceType": "ebs", 
            "OwnerId": "137112412989", 
            "RootDeviceName": "/dev/xvda", 
            "CreationDate": "2016-06-22T06:10:37.000Z", 
            "Public": true, 
            "ImageType": "machine", 
            "Description": "Amazon Linux AMI 2016.03.3 x86_64 HVM GP2"
        }
    ]
}

$ aws ec2 describe-images --region us-east-1 --image-ids ami-dc6aa9b1
{
    "Images": [
        {
            "VirtualizationType": "hvm", 
            "Name": "amzn-ami-hvm-2016.03.3.x86_64-s3", 
            "Hypervisor": "xen", 
            "ImageOwnerAlias": "amazon", 
            "SriovNetSupport": "simple", 
            "ImageId": "ami-dc6aa9b1", 
            "State": "available", 
            "BlockDeviceMappings": [], 
            "Architecture": "x86_64", 
            "ImageLocation": "amzn-ami-us-east-1/amzn-ami-hvm-2016.03.3.x86_64.manifest.xml", 
            "RootDeviceType": "instance-store", 
            "OwnerId": "137112412989", 
            "CreationDate": "2016-06-22T06:04:58.000Z", 
            "Public": true, 
            "ImageType": "machine", 
            "Description": "Amazon Linux AMI 2016.03.3 x86_64 HVM S3"
        }
    ]
}

@tpounds
Copy link
Contributor

tpounds commented Sep 27, 2016

I have a preliminary fix in https://github.com/tpounds/terraform/commit/e1e864a3dd87aab14e060b5b0df0c30b38083344 which seems to fix the issue. I'll submit a pull request once I do some more verification and add a few acceptance tests.

@michael-henderson
Copy link

@tpounds Any idea on an ETA for this getting merged? Thanks for the fix! :)

@clebio
Copy link

clebio commented Jun 11, 2018

Hello, I seem to have hit this error just now, and am not sure why -- has it resurfaced, or something else?

data "aws_ami" "main" {
  most_recent = true
  owners = ["137112412989"]
  filter {
    name   = "name"
    values = ["amzn-ami-hvm-*"]
  }
}
$ terraform version
Terraform v0.11.7
+ provider.aws v1.22.0

Apply yields:

* module.jenkins.aws_launch_configuration.main: 1 error(s) occurred:

* aws_launch_configuration.main: Expected to find a Root Device name for AMI (ami-40ce433f), but got none```
Thoughts?

@sgargan
Copy link

sgargan commented Aug 7, 2018

@clebio saw a similar issue which turned out to be the persmissions on the target ami making it public got me around this. Could be ^ is being incorrectly reported as a catchall for any kind of issue with the ami

@mildwonkey
Copy link
Contributor

Hi all,

Issues with the terraform aws provider should be opened in the aws provider repository.

Because this closed issue is generating notifications for subscribers, I am going to lock it and encourage anyone experiencing issues with the aws provider to open tickets there. (The other provider repositories are under the terraform-provider org).

Please continue to open issues here for any other terraform issues you encounter, and thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants