-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NRL-793] WIP workflow for building permissions
- Loading branch information
1 parent
c72606e
commit a80f2b3
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# Pull down all the lambda code for the named stack | ||
set -o errexit -o nounset -o pipefail | ||
|
||
: ${DIST_DIR:="./dist"} | ||
|
||
stack_name="$1" | ||
|
||
function pull_lambda_code(){ | ||
local api_name="$1" | ||
local endpoint_name="$2" | ||
local lambda_name="nhds-nrlf--${stack_name}--API-${api_name}--${endpoint_name}" | ||
|
||
echo "Downloading code for lambda ${lambda_name}...." | ||
code_url="$(aws lambda get-function --function-name ${lambda_name} | jq -r .Code.Location)" | ||
curl "${code_url}" > "${DIST_DIR}/${api_name}-${endpoint_name}.zip" | ||
} | ||
|
||
function pull_layer_code(){ | ||
local name="$1" | ||
local layer_name="nhds-nrlf--${stack_name}--${name}" | ||
local layer_version="$(aws lambda list-layer-versions --layer-name ${layer_name} | jq -r '.LayerVersions[0].Version')" | ||
local layer_pkg_name="$(echo ${layer_name} | tr '-' '_').zip" | ||
|
||
echo "Downloading code for layer ${layer_name} version ${layer_version}...." | ||
code_url="$(aws lambda get-layer-version --layer-name ${layer_name} --version-number ${layer_version} | jq -r .Content.Location)" | ||
curl "${code_url}" > "${DIST_DIR}/${layer_pkg_name}" | ||
} | ||
|
||
mkdir -p "${DIST_DIR}" | ||
|
||
echo "Pulling code for consumer API lambdas...." | ||
for endpoint_name in $(ls api/consumer) | ||
do | ||
pull_lambda_code "consumer" "${endpoint_name}" | ||
done | ||
|
||
echo "Pulling code for producer API lambdas...." | ||
for endpoint_name in $(ls api/producer) | ||
do | ||
pull_lambda_code "producer" "${endpoint_name}" | ||
done | ||
|
||
echo "Pulling code for layers...." | ||
for layer_name in nrlf dependency-layer nrlf-permissions | ||
do | ||
pull_layer_code "${layer_name}" | ||
done |