Created
April 20, 2020 17:11
-
-
Save shekodn/ade49af0ae36c0075faca5c279f11ff0 to your computer and use it in GitHub Desktop.
deploy script used for Deploying a Bastion Host in AWS using CloudFormation
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 | |
STACK_NAME=bastion-poc | |
REGION=us-east-1 | |
CLI_PROFILE=your-aws-profile-with-an-appropiate-role | |
EC2_INSTANCE_TYPE=t2.micro | |
KEY_NAME=your-key-pair-name | |
# Deploy the CloudFormation template | |
echo -e "\n\n=========== Deploying main.yml ===========" | |
aws cloudformation deploy --region $REGION \ | |
--profile $CLI_PROFILE \ | |
--stack-name $STACK_NAME \ | |
--template-file main.yml \ | |
--no-fail-on-empty-changeset \ | |
--capabilities CAPABILITY_NAMED_IAM \ | |
--parameter-overrides \ | |
EC2InstanceType=$EC2_INSTANCE_TYPE \ | |
KeyName=$KEY_NAME | |
# If the deploy succeeded, show the instances' IP address | |
if [ $? -eq 0 ]; then | |
aws cloudformation list-exports \ | |
--profile $CLI_PROFILE \ | |
--region $REGION \ | |
--query "Exports[?ends_with(Name,'Ip')].Value" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment