Created
December 26, 2017 18:17
-
-
Save saidach/34e0c4ddd6408e45cbcc8f4ffd362f86 to your computer and use it in GitHub Desktop.
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
files: | |
"/home/ec2-user/sourceenvname.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash | |
export AWS_DEFAULT_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/[a-z]$//') | |
instance_id=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) | |
ebenvname=$(aws --output text ec2 describe-tags --filters "Name=resource-id,Values=${instance_id}" "Name=key,Values=elasticbeanstalk:environment-name" | awk '{print $5}') | |
export ENV_NAME=$ebenvname | |
"/home/ec2-user/dev.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash | |
echo "this is Dev" > /tmp/test.tx | |
commands: | |
00-source-env: | |
command: "/home/ec2-user/sourceenvname.sh" | |
01-run-dev: | |
command: "/home/ec2-user/dev.sh" | |
test: '. /home/ec2-user/sourceenvname.sh && [[ $ENV_NAME == *"test-ebx"* ]]' | |
02-run-prod: | |
command: "/home/ec2-user/prod.sh" | |
test: '. /home/ec2-user/sourceenvname.sh && [[ $ENV_NAME == *"prod-ebx"* ]]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment