Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1. Find the latest ID of the AMI:
- NEW_AMI_ID=$(aws ec2 describe-images \
- --filters Name=name,Values=*WHATEVER AMI NAME YOU ARE LOOKING FOR* \
- --query 'Images[*].[ImageId,CreationDate]' \
- --output text | sort -k2 -r | head -n1 | awk {'print $1'})
- # 2. Modify a PARAMETERS.vars.json that is being used by AWS CLI in step 3.:
- tmp=$(mktemp)
- jq -r '[ .[] | select(.ParameterKey=="AmiId").ParameterValue |= '\"$NEW_AMI_ID\"' ]' \
- PARAMETERS.vars.json > "$tmp" && mv "$tmp" PARAMETERS.vars.json
- # 3. Create a stack using the above file with the latest AMI ID:
- AWS_PROFILE=test aws cloudformation create-stack \
- --stack-name WHATEVER \
- --template-body file://WHATEVER.template.yaml \
- --tags Key=BLA,Value=BLA \
- --parameters file://PARAMETERS.vars.json \
- --capabilities CAPABILITY_NAMED_IAM \
- --profile ${AWS_PROFILE}
Add Comment
Please, Sign In to add comment