Using a different AWS credentials with Packer
31 Dec 2018 | tags: Packer AWSRationale
Let’s supose you have multiple AWS credentials configured in your ~/.aws/credentials file. Using Packer you have multiple options to set the credentials to use (using environment variables or hardcoding the credentials in the Packer build file). But what happens if you don’t want to do such things and instead let Packer use different profile in your credentials’ file?
### Using AWS_DEFAULT_PROFILE to let Packer know what profile to use
It’s as easy as using the AWS_DEFAULT_PROFILE variable. That variable tells Packer which credentials to use. That way you don’t need to export or hardcode the credentials anywhere.
Usage
It’d be as simple as:
AWS_DEFAULT_PROFILE=myCredentials packer build ami.json
It seems the AWS_DEFAULT_PROFILE comes from the Python AWS package.
[1] https://github.com/hashicorp/packer/issues/2471