简体   繁体   English

Packer将现有的ebs卷附加到AMI

[英]Packer attach existing ebs-volume to AMI

I am trying to attach an existing amazon ebs-volume with some pre-loaded information on my AMI using packer but I haven't found a way to do it. 我正在尝试使用打包程序在AMI上附加现有的亚马逊ebs卷以及一些预加载的信息,但是我还没有找到一种方法。

Looking at the packer documentation I'm pretty sure that what I'm looking for is a amazon-ebssurrogate builder. 查看打包程序文档,我很确定我要寻找的是amazon-ebssurrogate构建器。 But I don't see any option to specify the volume-id. 但是我看不到任何指定volume-id的选项。 I have seen many examples on how to create a new volume and attach it. 我已经看到了许多有关如何创建新卷并将其附加的示例。 But not any example of doing this with an existing volume. 但是,没有任何对现有卷执行此操作的示例。 This is my current packer file at the moment: 这是我当前的打包程序文件:

{
    "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"
        }
    ]
}

Any feedback or pointers on how to achieve this will be greatly appreciated. 任何有关如何实现此目标的反馈或建议,将不胜感激。

拍摄该卷的快照,并在ami_block_device_mappingslaunch_block_device_mappings中进行引用

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

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