简体   繁体   中英

Packer: Generate AMI from a running EC2 Instance

I woud like to create an AMI (Amazon Machine Image) from a running EC2 instance using Packers..

Here is my usecase:
1) Use packer to generate the base AMI and start the EC2 instance
2) Have user data configuration on the EC2 instance.. (Human Intervention needed here)
3) Generate an app specific AMI from step#2 using Packer

I don't want to use the "provisioner" provided by packers. I need a human intervention at step#2

The point of Packer seems to be to eliminate human intervention from the build process in order to make deployment consistent. However, per-instance data can be passed in through Packer user variables , which can be passed on the command line:

$ packer build \
    -var 'aws_access_key=foo' \
    -var 'aws_secret_key=bar' \
    template.json

or via a config file:

$ packer build -var-file=variables.json template.json

I would agree with the ec2-create-image approach. Once your packer build completes- you would need a second packer build to accomplish this. You could have a webhook kick this off, say, with Atlas.

Have you considered doing the modifications locally (in VMWare) and then installing ec2 tools, and using ec2-convert? something like the following?

aws ec2 import-image --cli-input-json '{ "Platform": "Linux", 
"Architecture": "x86_64", "Description": "Some Centos AMI v21.2.1", 
"DiskContainers": [{ "Description": "Some_App", "UserBucket": { 
"S3Bucket": "centos-builds", "S3Key": "some-build-ami.ova"}}]}'

This will end with an AMI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM