在packer配置文件中设置aws的可切换角色
时间: 2023-12-10 18:36:59 浏览: 146
packer-aws-kafka:Packer模板以构建AWS Apache Kafka AMI
要在Packer配置文件中设置AWS可切换角色,您需要使用以下JSON代码:
```
{
"builders": [{
"type": "amazon-ebs",
"access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"region": "us-east-1",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*",
"root-device-type": "ebs"
},
"most_recent": true,
"owners": ["099720109477"]
},
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "ubuntu-xenial-16.04-amd64-server-{{timestamp}}",
"run_tags": {
"Name": "Packer Builder"
},
"assume_role": {
"role_arn": "arn:aws:iam::123456789012:role/myrole",
"session_name": "packer"
}
}]
}
```
在上面的代码中,您需要将 "role_arn" 值更改为 AWS 中您希望使用的角色 ARN。然后,Packer 将使用此角色进行部署。
阅读全文