diff --git a/aws/src/main/python/beam_lambda/lambda_function.py b/aws/src/main/python/beam_lambda/lambda_function.py index 3776a47bbf5..53015985459 100755 --- a/aws/src/main/python/beam_lambda/lambda_function.py +++ b/aws/src/main/python/beam_lambda/lambda_function.py @@ -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."''' @@ -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----------------------" @@ -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" @@ -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']) \ diff --git a/aws/src/main/python/runPilates/lambda_function.py b/aws/src/main/python/runPilates/lambda_function.py index c95570b9903..1833ac02f20 100644 --- a/aws/src/main/python/runPilates/lambda_function.py +++ b/aws/src/main/python/runPilates/lambda_function.py @@ -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') @@ -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)