Unable to launch AWS Linux 2 instance

783 views
Skip to first unread message

Greg Coit

unread,
Jul 10, 2019, 10:21:21 PM7/10/19
to Packer
Using the defaults I get from the AWS dashboard, I have:

    "launch_block_device_mappings": [
    {
      "device_name": "/dev/xvda",
      "volume_type": "gp2",
      "volume_size": 8,
      "snapshot_id": "snap-08091107f3acb12b2",
      "delete_on_termination": true
    }
  ]

But I'm getting this error:

amazon-ebs: Error launching source instance: MissingParameter: The request must contain the parameter size or snapshotId

I found this bug report which is very similar: 


 But I don't understand the answer provided.

any suggestions?  

Thanks!

Greg
  

Greg Coit

unread,
Jul 10, 2019, 10:22:32 PM7/10/19
to Packer
FWIW, I've tried it with and without the snapshot_id and volume_size in any combination I can think of.

Greg

Rickard von Essen

unread,
Jul 11, 2019, 5:24:23 AM7/11/19
to packe...@googlegroups.com
What are you trying to achieve? Why do you include the launch_block_device_mappings?

What is the describe-images outputfor the source_ami? 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/465bd44c-b033-4f70-a72f-26b263c9e8a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Greg Coit

unread,
Jul 11, 2019, 11:49:22 AM7/11/19
to Packer
This is the describe-images for the Amazon Linux 2 instance I want to use:  

{
    "Images": [
        {
            "VirtualizationType": "hvm",
            "Description": "Amazon Linux 2 AMI 2.0.20190618 x86_64 HVM gp2",
            "Hypervisor": "xen",
            "ImageOwnerAlias": "amazon",
            "EnaSupport": true,
            "SriovNetSupport": "simple",
            "ImageId": "ami-0b898040803850657",
            "State": "available",
            "BlockDeviceMappings": [
                {
                    "DeviceName": "/dev/xvda",
                    "Ebs": {
                        "Encrypted": false,
                        "DeleteOnTermination": true,
                        "VolumeType": "gp2",
                        "VolumeSize": 8,
                        "SnapshotId": "snap-08091107f3acb12b2"
                    }
                }
            ],
            "Architecture": "x86_64",
            "ImageLocation": "amazon/amzn2-ami-hvm-2.0.20190618-x86_64-gp2",
            "RootDeviceType": "ebs",
            "OwnerId": "137112412989",
            "RootDeviceName": "/dev/xvda",
            "CreationDate": "2019-06-19T21:59:15.000Z",
            "Public": true,
            "ImageType": "machine",
            "Name": "amzn2-ami-hvm-2.0.20190618-x86_64-gp2"
        }
    ]
}

What I'm attempting to do is launch an instance from this AMI, modify it, and make my own AMI.

We're able to do this with Centos7 - I cloned that packer script and modified it do the same for Amazon LInux 2.

Thank you,

Greg

Rickard von Essen

unread,
Jul 11, 2019, 1:08:25 PM7/11/19
to packe...@googlegroups.com
Since you don't seems to change anything, just remove the launch_block_device_mappings section of your packer template. Or do you want to change anything? 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Greg Coit

unread,
Jul 11, 2019, 1:16:19 PM7/11/19
to Packer
I don't need to change anything.  Unfortunately, that doesn't work either (same error of amazon-ebs: Error launching source instance: MissingParameter: The request must contain the parameter size or snapshotId).  Here's my json file:

{
  "variables": {
    "aws_access_key_id": "",
    "aws_secret_access_key": ""
  },
  "builders": [{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key_id`}}",
    "secret_key": "{{user `aws_secret_access_key`}}",
    "region": "us-east-1",
    "vpc_id": "REDACTED",
    "subnet_id": "REDACTED",
    "source_ami_filter": {
      "filters": {
      "virtualization-type": "hvm",
      "name": "*amzn2-ami-hvm-2.0*",
      "name": "*gp2*",
      "platform": "Amazon Linux",
      "architecture": "x86_64",
      "root-device-type": "ebs"
      },
      "owners": ["137112412989"],
      "most_recent": true
    },
    "instance_type": "t2.micro",
    "ssh_username": "ec2-user",
    "ami_name": "REDACTED",
    "ami_description": "REDACTED",
    "ami_regions": [
      "us-east-1",
      "us-west-1",
      "us-west-2",
      "ap-northeast-1",
      "ap-southeast-1",
      "ap-southeast-2",
      "eu-west-1",
      "sa-east-1"
    ],
    "ami_users": [
      "REDACTED"
     
    ]
  }],
  "provisioners":[
    {
    "type": "shell",
    "inline": [
      "sleep 30"
      ]
    },
    {
    "type": "shell",
    "script": "01_system_repos_and_kernels.sh"
    },
    {
    "type": "shell",
    "inline": [
      "sudo /sbin/reboot"
      ]
    },
    {
    "type": "shell",
    "pause_before": "30s",
    "script": "02_userland_packages.sh"
    },
    {
    "type": "shell",
    "inline": [
      "sudo /sbin/reboot"
      ]
    },
    {
    "type": "shell",
    "pause_before": "30s",
    "scripts": [
      "91_cleanup.sh"
      ]
    }
  ]
}

Greg Coit

unread,
Jul 11, 2019, 1:16:50 PM7/11/19
to Packer
I'm using Packer v1.4.2 btw

Rickard von Essen

unread,
Jul 11, 2019, 1:23:39 PM7/11/19
to packe...@googlegroups.com
Your source_ami_filters have name twice. Remove one, also try to use source_ami to verify that the problem isn't with your filter. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Greg Coit

unread,
Jul 11, 2019, 1:29:31 PM7/11/19
to Packer
Good suggestion.  Unfortunately, I'm getting the same error still.  Here's the json file:

{
  "variables": {
    "aws_access_key_id": "",
    "aws_secret_access_key": ""
  },
  "builders": [{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key_id`}}",
    "secret_key": "{{user `aws_secret_access_key`}}",
    "region": "us-east-1",
    "vpc_id": "REDACTED",
    "subnet_id": "REDACTED",
    "source_ami": "ami-0b898040803850657",

Rickard von Essen

unread,
Jul 11, 2019, 3:32:16 PM7/11/19
to packe...@googlegroups.com
Don't really know why you get this problem, this works for me:

$ cat template.json
{
  "builders": [{
    "type": "amazon-ebs",
    "region": "us-east-1",

    "source_ami": "ami-0b898040803850657",
    "instance_type": "t2.micro",
    "ssh_username": "ec2-user",
    "ami_name": "REDACTED"
  }]
}
$ packer version
Packer v1.4.3-dev (39076f82e+CHANGES)
$ env AWS_PROFILE=packer-demo packer build --force template.json
amazon-ebs output will be in this color.

==> amazon-ebs: Force Deregister flag found, skipping prevalidating AMI Name
    amazon-ebs: Found Image ID: ami-0b898040803850657
==> amazon-ebs: Creating temporary keypair: packer_5d277b09-f8c4-1256-af38-998b9f3cc52b
==> amazon-ebs: Creating temporary security group for this instance: packer_5d277b0b-65bf-5d08-1a2f-e63c32edd759
==> amazon-ebs: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
    amazon-ebs: Adding tag: "Name": "Packer Builder"
    amazon-ebs: Instance ID: i-0f5e792c4b313ab4f
==> amazon-ebs: Waiting for instance (i-0f5e792c4b313ab4f) to become ready...
==> amazon-ebs: Using ssh communicator to connect: 52.90.41.137
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Stopping the source instance...
    amazon-ebs: Stopping instance
==> amazon-ebs: Waiting for the instance to stop...
==> amazon-ebs: Deregistered AMI REDACTED, id: ami-08cbc649096e89485
==> amazon-ebs: Creating AMI REDACTED from instance i-0f5e792c4b313ab4f
    amazon-ebs: AMI: ami-048281d412997f871
==> amazon-ebs: Waiting for AMI to become ready...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' finished.

==> Builds finished. The artifacts of successful builds are:
--> amazon-ebs: AMIs were created:
us-east-1: ami-048281d412997f871

I suggest that you remove most things from your template or start with mine above and add thinks, and rebuild until you find what change introduces the error.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Greg Coit

unread,
Jul 12, 2019, 4:07:45 PM7/12/19
to Packer
Rickard,

I appreciate all your help. 

We've determined, after all this, that we can use the Amazon Linux 2 AMI without modification unlike the Centos 7 AMIs which require the addition of enhanced networking drivers.

I hope something in this thread is helpful to the next person.

Greg
To unsubscribe from this group and stop receiving emails from it, send an email to packe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages