Docker AMI Build with Packer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
echo "Gathering AWS Credentials..." | |
AWS_ACCESS_KEY=$(aws configure get aws_access_key_id --profile=$1) | |
AWS_SECRET_KEY=$(aws configure get aws_secret_access_key --profile=$1) | |
AWS_REGION=$(aws configure get region --profile=$1) | |
AWS_ACCOUNT_ID=$(aws ec2 describe-security-groups --group-names 'Default' --query 'SecurityGroups[0].OwnerId' --output text --profile=$1) | |
echo "AWS Account ID: $AWS_ACCOUNT_ID" | |
echo "AWS Access Key ID: $AWS_ACCESS_KEY" | |
echo "AWS Secret Access Key ID: $AWS_SECRET_KEY" | |
echo "AWS Region: $AWS_REGION" | |
packer build \ | |
-var "aws_access_key=$AWS_ACCESS_KEY" \ | |
-var "aws_secret_key=$AWS_SECRET_KEY" \ | |
-var "aws_account_id=$AWS_ACCOUNT_ID" \ | |
-var "aws_region=$AWS_REGION" \ | |
packer.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment