Packer将现有的ebs卷附加到AMI

时间:2019-08-27 23:05:11

标签: amazon-web-services amazon-ec2 devops packer

我正在尝试使用Packer在我的AMI上附加一个现有的亚马逊ebs卷以及一些预加载的信息,但是我还没有找到一种方法。

在查看打包程序文档时,我非常确定我要寻找的是amazon-ebssurrogate构建器。但是我看不到任何指定volume-id的选项。我已经看到了许多有关如何创建新卷并将其附加的示例。但是,没有任何对现有卷执行此操作的示例。这是我当前的打包程序文件:

{
    "variables": {
        "modified_by": "{{env `USER`}}",
        "aws_access_key": "{{user `aws_access_key`}}",
        "aws_secret_key": "{{user `aws_secret_key`}}",
        "aws_bamboo_ami": "{{user `aws_ubuntu_ami`}}"
    },

    "builders": [{
        "type": "amazon-ebs",
        "vpc_id": "vpc-12345",
        "subnet_id": "subnet-12345",
        "access_key": "{{user `aws_access_key`}}",
        "secret_key": "{{user `aws_secret_key`}}",
        "region": "us-east-1",
        "availability_zone": "us-east-1b",
        "source_ami": "{{user `aws_ubuntu_ami`}}",
        "instance_type": "m5.xlarge",
        "ssh_username": "ubuntu",
        "ami_name": "{{user `modified_by`}} bamboo-server-stock-ami {{timestamp}}",
        "tags": {
            "Name": "Stock-Bamboo-Ubuntu-Server-Image",
            "business_unit": "Commercial:Release",
            "service": "opensource.atlassian.com",
            "resource_owner": "{{user `modified_by`}}",
            "service_tier": "app",
            "environment": "dev"
        }
    }],

    "provisioners": [
        {
            "type": "shell", 
            "scripts": [
                "../scripts/ansible-ubuntu.sh"
            ]
        },
        {
            "type": "ansible-local",
            "playbook_dir": "../playbooks",
            "playbook_file": "../playbooks/bamboo-server.yml",
            "extra_arguments": "-vvvvv"
        }
    ]
}

对于实现此目标的任何反馈或建议,我们将不胜感激。

1 个答案:

答案 0 :(得分:0)

制作卷的快照,并在ami_block_device_mappings launch_block_device_mappings 中进行引用。