Skip to content

Commit

Permalink
Add ability to skip SAM build in package-transform (#205)
Browse files Browse the repository at this point in the history
**Why:**

The AWS Serverless Application Model (SAM) build action tries to fetch
all requirements specified in the `requirements.txt`.

However, this does not work when you would like to use other sources to
host the python modules than the default public one.

**How:**

In order to skip the `sam build` step, specify the `--no-build` flag to
the `package_transform.sh` script.
  • Loading branch information
sbkok authored and bundyfx committed Jan 10, 2020
1 parent 8b9ee6f commit 8a73568
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions ...odebase/initial_commit/bootstrap_repository/adf-build/shared/helpers/package_transform.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
#!/bin/bash

set -e

#
# This script will package all source code and send it to an S3 bucket in each region
# where the lambda needs to be deployed to.
#
# ADF_PROJECT_NAME is an environment variable that is passed to the CodeBuild Project
# CODEBUILD_SRC_DIR is an environment variable provided by CodeBuild

set -e

SKIP_BUILD=0

# Walk through the options passed to this script
for i in "$@"
do
case $i in
--no-build)
SKIP_BUILD=1
;;
*)
echo "Unknown option: $i"
exit 1
;;
esac
done

pip install --upgrade awscli aws-sam-cli -q

# Build our template and its potential dependancies
sam build
if [[ $SKIP_BUILD == 0 ]]; then
echo "Perform build step"
# Build our template and its potential dependencies
sam build
else
echo "Skip build step"
fi

# Get list of regions supported by this application
echo "Determine which regions need to be prepared"
app_regions=`aws ssm get-parameters --names /deployment/$ADF_PROJECT_NAME/regions --with-decryption --output=text --query='Parameters[0].Value'`
# Convert json list to bash list (space delimited regions)
regions="`echo $app_regions | sed -e 's/\[\([^]]*\)\]/\1/g' | sed 's/,/ /g' | sed "s/'//g"`"
Expand Down

0 comments on commit 8a73568

Please sign in to comment.