version: 0.2 phases: install: commands: - yum install -y jq build: commands: - printenv - ls ./ - echo "zipping files" - zip -j templates.zip templates/*.json - export OBJECT_KEY=templates/${CODEBUILD_RESOLVED_SOURCE_VERSION}/policies.zip && echo $OBJECT_KEY post_build: commands: - echo "Uploading file to ${BUCKET_NAME}/${OBJECT_KEY}" - aws s3 cp ./templates.zip "s3://${BUCKET_NAME}/${OBJECT_KEY}" - echo "Updating Lambda Env var" - config=$(aws lambda get-function-configuration --function-name ${LAMBDA_ID}) && echo $config - lambda_env=$(echo $config | jq -r --arg template_key $OBJECT_KEY '.Environment.Variables.TEMPLATE_KEY = $template_key | .Environment') && echo $lambda_env - aws lambda update-function-configuration --function-name ${LAMBDA_ID} --environment "${lambda_env}" - echo Entered the post_build phase... - echo Build completed on `date` artifacts: files: - templates.zip discard-paths: yes cache: paths: - "/root/.m2/**/*"