Skip to content

Commit

Permalink
Append stop behavior to tag and backup location to tag (#2292)
Browse files Browse the repository at this point in the history
* Append stop behavior to name

* Add backup data to tag
  • Loading branch information
JustinPihony authored and REASY committed Dec 14, 2019
1 parent 14add76 commit 48d9cb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion aws/src/main/python/beam_lambda/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
- done;
- sudo cp /var/log/cloud-init-output.log "$finalPath"
- sudo aws --region "$S3_REGION" s3 cp "$finalPath" s3://beam-outputs/"$finalPath" --recursive;
- s3p="$s3p, https://s3.us-east-2.amazonaws.com/beam-outputs/index.html#$finalPath"'''
- s3p="$s3p, https://s3.us-east-2.amazonaws.com/beam-outputs/index.html#$finalPath"
- sudo aws --region "$S3_REGION" s3 ls s3://beam-outputs/$finalPath | wc -l
- s3_output_count = $?'''

END_SCRIPT_DEFAULT = '''echo "End script not provided."'''

Expand Down Expand Up @@ -91,6 +93,7 @@
- /tmp/slack.sh "$hello_msg"
- /home/ubuntu/git/glip.sh -i "http://icons.iconarchive.com/icons/uiconstock/socialmedia/32/AWS-icon.png" -a "Run Started" -b "Run Name** $TITLED** \\n Instance ID $(ec2metadata --instance-id) \\n Instance type **$(ec2metadata --instance-type)** \\n Host name **$(ec2metadata --public-hostname)** \\n Web browser **http://$(ec2metadata --public-hostname):8000** \\n Region $REGION \\n Batch $UID \\n Branch **$BRANCH** \\n Commit $COMMIT"
- s3p=""
- s3_output_count=0
- for cf in $CONFIG
- do
- echo "-------------------running $cf----------------------"
Expand All @@ -101,6 +104,10 @@
- then
- s3glip="\\n S3 output url ${s3p#","}"
- fi
- if [ $s3_output_count > 0 ]
- then
- sudo aws ec2 create-tags --region $REGION --resources $(ec2metadata --instance-id) --tags Key=BackedUp,Value=$s3p
- fi
- bye_msg=$(printf "Run Completed \\n Run Name** $TITLED** \\n Instance ID %s \\n Instance type **%s** \\n Host name **%s** \\n Web browser ** http://%s:8000 ** \\n Region $REGION \\n Batch $UID \\n Branch **$BRANCH** \\n Commit $COMMIT %s \\n Shutdown in $SHUTDOWN_WAIT minutes" $(ec2metadata --instance-id) $(ec2metadata --instance-type) $(ec2metadata --public-hostname) $(ec2metadata --public-hostname) "$s3glip")
- echo "$bye_msg"
- /tmp/slack.sh "$bye_msg"
Expand Down Expand Up @@ -291,6 +298,7 @@ def deploy_handler(event):
for arg in params:
uid = str(uuid.uuid4())[:8]
runName = titled
runName = runName + '_' + shutdown_behaviour.toUpperCase()
if len(params) > 1:
runName += "-" + `runNum`
script = initscript.replace('$RUN_SCRIPT',selected_script).replace('$REGION',region).replace('$S3_REGION',os.environ['REGION']) \
Expand Down
4 changes: 2 additions & 2 deletions aws/src/main/python/runPilates/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def get_param(param_name):
missing_parameters.append(param_name)
return param_value

run_name = get_param('runName')
shutdown_behaviour = get_param('shutdownBehaviour')
run_name = get_param('runName') + '_' + shutdown_behaviour.toUpperCase()
initial_urbansim_input = get_param('initialS3UrbansimInput')
branch = get_param('beamBranch')
commit_id = get_param('beamCommit')
Expand All @@ -336,7 +337,6 @@ def get_param(param_name):
instance_type = get_param('instanceType')
volume_size = get_param('storageSize')
region = get_param('region')
shutdown_behaviour = get_param('shutdownBehaviour')

if missing_parameters:
return "Unable to start, missing parameters: " + ", ".join(missing_parameters)
Expand Down

0 comments on commit 48d9cb7

Please sign in to comment.