Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -ex
  4.  
  5. echo "Gathering AWS Credentials..."
  6.  
  7. AWS_ACCESS_KEY=$(aws configure get aws_access_key_id --profile=$1)
  8. AWS_SECRET_KEY=$(aws configure get aws_secret_access_key --profile=$1)
  9. AWS_REGION=$(aws configure get region --profile=$1)
  10. AWS_ACCOUNT_ID=$(aws ec2 describe-security-groups --group-names 'Default' --query 'SecurityGroups[0].OwnerId' --output text --profile=$1)
  11.  
  12. echo "AWS Account ID: $AWS_ACCOUNT_ID"
  13. echo "AWS Access Key ID: $AWS_ACCESS_KEY"
  14. echo "AWS Secret Access Key ID: $AWS_SECRET_KEY"
  15. echo "AWS Region: $AWS_REGION"
  16.  
  17. packer build \
  18. -var "aws_access_key=$AWS_ACCESS_KEY" \
  19. -var "aws_secret_key=$AWS_SECRET_KEY" \
  20. -var "aws_account_id=$AWS_ACCOUNT_ID" \
  21. -var "aws_region=$AWS_REGION" \
  22. packer.json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement