Packer“未使用-var或静态凭据为AWS builder找到有效的凭据源”

时间:2018-03-16 18:42:57

标签: packer

我正在尝试使用打包器构建一个基本的ami图像,我嵌入了我的access_key和密钥,但我仍然得到标题错误。

我的包装工模板文件:

{
    "builders": [{
        "name": "packer-ex",
        "type": "amazon-ebs",
        "access_key": "",
        "secret_key": "",
        "region": "us-west-2",
        "source_ami_filter": {
            "filters": {
                "virtualization-type": "hvm",
                "name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
                "root-device-type": "ebs"
            },
            "owners": ["099720109477"],
            "most_recent": true
       },
        "instance_type": "t2.micro",
        "ssh_username": "ubuntu",
        "ami_name": "packer-example {{timestamp}}"
    }],
    "provisioners": [{
        "type": "shell",
        "inline":[
            "sleep 30",
            "sudo apt-get update",
            "sudo apt-get install -y apache2",
            "sudo apt-get install mysql",
            "sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql",
            "sudo systemctl restart apache2"
        ]
     }]
}

1 个答案:

答案 0 :(得分:1)

最简单的解决方案是配置具有凭据和正确访问权限(aws --profile=<profile> configure)的配置文件,然后通过显式设置环境变量AWS_PROFILE运行Packer时使用该配置文件。即AWS_PROFILE=<profile> packer build template.json