Reputation: 13
I am trying to build a basic ami image using packer, I embed my access_key and secret-key but I still get the title error.
My packer template file:
{
"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"
]
}]
}
Upvotes: 0
Views: 4420
Reputation: 4288
The simplest solution is to configure a profile with credentials ans the correct access rights (aws --profile=<profile> configure
) and then use that when running Packer by explicitly setting the environment variable AWS_PROFILE
. I.e. AWS_PROFILE=<profile> packer build template.json
Upvotes: 3