简体   繁体   English

Packer:从正在运行的EC2实例生成AMI

[英]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.. 我想使用Packers从正在运行的EC2实例创建AMI(亚马逊机器映像)。

Here is my usecase: 这是我的用例:
1) Use packer to generate the base AMI and start the EC2 instance 1)使用packer生成基本AMI并启动EC2实例
2) Have user data configuration on the EC2 instance.. (Human Intervention needed here) 2)在EC2实例上进行用户数据配置..(此处需要人工干预)
3) Generate an app specific AMI from step#2 using Packer 3)使用Packer从步骤#2生成特定于应用程序的AMI

I don't want to use the "provisioner" provided by packers. 我不想使用包装工提供的“供应商”。 I need a human intervention at step#2 我需要在第2步进行人工干预

The point of Packer seems to be to eliminate human intervention from the build process in order to make deployment consistent. Packer的观点似乎是消除构建过程中的人为干预,以使部署保持一致。 However, per-instance data can be passed in through Packer user variables , which can be passed on the command line: 但是,每个实例数据可以通过Packer 用户变量传递,这些变量可以在命令行上传递:

$ 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. 我同意ec2-create-image方法。 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. 比如说,你可以用Atlas进行一次webhook踢。

Have you considered doing the modifications locally (in VMWare) and then installing ec2 tools, and using ec2-convert? 您是否考虑过在本地进行修改(在VMWare中),然后安装ec2工具,并使用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. 这将以AMI结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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