Terraform-provider-aws: Error finding Root Device Name for AMI

Created on 3 Aug 2018  路  3Comments  路  Source: hashicorp/terraform-provider-aws

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


Terraform Version

...
Terraform v0.11.7

Terraform Configuration Files

...
resource "aws_launch_configuration" "zoopusers-lc" {
  name = "zoopusers-${var.environment}-${var.zoopusers_ami}"

  image_id = "${var.zoopusers_ami}"

  instance_type        = "${var.zoopusers_instance_type}"
  iam_instance_profile = "${var.zoopusers_instance_profile}"

  security_groups = [
    "${aws_security_group.zoopusers.id}",
    "${var.sg_ssh}",
    "${var.sg_services}",
  ]

  lifecycle {
    create_before_destroy = true
  }

  root_block_device {
    volume_type = "gp2"
    volume_size = "30"
  }
}

Debug Output

Crash Output

Expected Behavior

Actual Behavior


[WARN] Error finding Root Device Name for AMI

Steps to Reproduce

Additional Context

References

documentation servicec2

Most helpful comment

For us, this issue was caused by the fact that the AMI lived in a different AWS account and we forgot to give our AWS account access to it. If you're using Packer to build your AMIs, you can share them with another account by adding the ami_users setting to your builder:

  "builders": [{
    "name": "foo",
    "ami_name": "bar-{{uuid | clean_ami_name}}",
    "instance_type": "t2.micro",
    "region": "us-west-2",
    "type": "amazon-ebs",
    "source_ami_filter": {
      "filters": {
        "virtualization-type": "hvm",
        "architecture": "x86_64",
        "name": "*ubuntu-xenial-16.04-amd64-server-*",
        "block-device-mapping.volume-type": "gp2",
        "root-device-type": "ebs"
      },
      "owners": ["099720109477"],
      "most_recent": true
    },
    "encrypt_boot": false,
    "ssh_username": "ubuntu",
    "ami_users": ["111111111111", "222222222222"]
  }],

All 3 comments

Ran into this tonight and resolved by another person's suggestion to make the AMI public. This is not ideal. Image was generated and pushed to AWS via Packer 1.3.1 and used in an ASG with Terraform 0.11.8 and AWS Provider 1.39.0. Putting the image back to private immediately raises the error again.

aws_launch_configuration.this: Expected to find a Root Device name for AMI (ami-043bcd95df5310XXX), but got none

For us, this issue was caused by the fact that the AMI lived in a different AWS account and we forgot to give our AWS account access to it. If you're using Packer to build your AMIs, you can share them with another account by adding the ami_users setting to your builder:

  "builders": [{
    "name": "foo",
    "ami_name": "bar-{{uuid | clean_ami_name}}",
    "instance_type": "t2.micro",
    "region": "us-west-2",
    "type": "amazon-ebs",
    "source_ami_filter": {
      "filters": {
        "virtualization-type": "hvm",
        "architecture": "x86_64",
        "name": "*ubuntu-xenial-16.04-amd64-server-*",
        "block-device-mapping.volume-type": "gp2",
        "root-device-type": "ebs"
      },
      "owners": ["099720109477"],
      "most_recent": true
    },
    "encrypt_boot": false,
    "ssh_username": "ubuntu",
    "ami_users": ["111111111111", "222222222222"]
  }],

Also ran into this, in my case the problem was AMI stuck in "pending" state, so I've recreated it.

Was this page helpful?
0 / 5 - 0 ratings