From bf4ab1f4a21359236ae2a4838bee9e05506b3ff8 Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 09:49:25 +0100 Subject: [PATCH 1/7] Adds app-file parameter --- README.md | 2 ++ action.yml | 5 +++++ deploy.sh | 11 ++++++----- destroy.sh | 11 ++++++----- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a05ed9e..4038c15 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Currently, the action supports: | add-branch-suffix | boolean | no | false | Appends a commit hash to the Stack ID | | ephemeral | boolean | no | false | Destroys the Stack at the end of the Job | | parameters | string | no | "" | CfnParameters of the form `k1=v1 k2=v2 ...` | +| app-file | string | no | "app.py | Path to the CDK App file | ## Action Outputs @@ -52,6 +53,7 @@ jobs: Parameter1=Value1 Parameter2=Value2 Parameter3=Value3 + app_file: ./aws/app.py - name: Access Stack Output run: echo ${{ fromJSON(steps.deploy.outputs.stack-output).MyCustomValue }} ``` diff --git a/action.yml b/action.yml index af8f732..ca59a0b 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,10 @@ inputs: description: CfnParameters of the form `k1=v1 k2=v2 ...` required: false default: "" + app-file: + description: The path to the CDK app file + required: false + default: "app.py" runs: using: docker image: Dockerfile @@ -26,3 +30,4 @@ runs: - ${{ inputs.stack-id }} - ${{ inputs.add-branch-suffix }} - ${{ inputs.parameters }} + - ${{ inputs.app-file }} diff --git a/deploy.sh b/deploy.sh index 87a847d..7f64f25 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,9 +3,10 @@ STACK_ID=${1} ADD_STACK_SUFFIX=${2} PARAMETER_STRING=${3} +APP_FILE=${4} CFN_PARAMETERS=${PARAMETER_STRING} FULL_STACK_ID=${STACK_ID} -UNSCOPED_APP=app.py.tmp +UNSCOPED_APP=${APP_FILE}.tmp OUTPUT_FILE=.cdk-outputs.json CDK_PROJECT=/github/workspace @@ -14,8 +15,8 @@ cd ${CDK_PROJECT} if [ ${ADD_STACK_SUFFIX} == "true" ]; then git config --global --add safe.directory ${CDK_PROJECT} FULL_STACK_ID=${STACK_ID}$(git rev-parse --short HEAD) - mv app.py ${UNSCOPED_APP} - sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > app.py + mv ${APP_FILE} ${UNSCOPED_APP} + sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > ${APP_FILE} fi for PARAMETER in ${PARAMETER_STRING}; do @@ -33,8 +34,8 @@ chmod a+rw -R cdk.out chmod a+rw -R ${OUTPUT_FILE} if [ ${ADD_STACK_SUFFIX} == "true" ]; then - rm app.py - mv ${UNSCOPED_APP} app.py + rm ${APP_FILE} + mv ${UNSCOPED_APP} ${APP_FILE} fi echo "stack-output=$(cat ${OUTPUT_FILE} | jq -c --arg ID ${FULL_STACK_ID} '.[$ID]')" >> $GITHUB_OUTPUT diff --git a/destroy.sh b/destroy.sh index 67402ab..2348e77 100755 --- a/destroy.sh +++ b/destroy.sh @@ -2,8 +2,9 @@ STACK_ID=${1} ADD_STACK_SUFFIX=${2} +APP_FILE=${3} FULL_STACK_ID=${STACK_ID} -UNSCOPED_APP=app.py.tmp +UNSCOPED_APP=${APP_FILE}.tmp CDK_PROJECT=/github/workspace cd ${CDK_PROJECT} @@ -13,15 +14,15 @@ if [ ${INPUT_EPHEMERAL} == "true" ]; then if [ ${ADD_STACK_SUFFIX} == "true" ]; then git config --global --add safe.directory ${CDK_PROJECT} FULL_STACK_ID=${STACK_ID}$(git rev-parse --short HEAD) - mv app.py ${UNSCOPED_APP} - sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > app.py + mv ${APP_FILE} ${UNSCOPED_APP} + sed "s/\"${STACK_ID}\"/\"${FULL_STACK_ID}\"/g" ${UNSCOPED_APP} > ${APP_FILE} fi cdk destroy --force --exclusively ${FULL_STACK_ID} if [ ${ADD_STACK_SUFFIX} == "true" ]; then - rm app.py - mv ${UNSCOPED_APP} app.py + rm ${APP_FILE} + mv ${UNSCOPED_APP} ${APP_FILE} fi else From fad84c8cec3637c713a77589a413b2763b7e682b Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 10:18:46 +0100 Subject: [PATCH 2/7] Adds additional dependencies --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index afd077c..204d769 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,10 @@ RUN apk add --no-cache \ git \ jq RUN pip3 install \ - aws-cdk-lib==2.93.0 \ - constructs==10.2.70 + aws-cdk.aws-cognito-identitypool-alpha==2.144.0a0 \ + aws-cdk-lib==2.144.0 \ + constructs==10.3.0 \ + cdk-nag==2.28.130 COPY ./deploy.sh /deploy.sh COPY ./destroy.sh /destroy.sh \ No newline at end of file From 543fb701eb3265450c1e168f194ff80046d8ef56 Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 10:22:27 +0100 Subject: [PATCH 3/7] Bumps aws-cdk cli version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 204d769..922065e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:20-alpine3.17 -RUN npm install -g aws-cdk@2.99.1 +RUN npm install -g aws-cdk@2.144.0 RUN apk add --no-cache \ py3-pip \ git \ From 36a17369cf33f7fa9aef6eafc0684c6a10c95901 Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 10:26:26 +0100 Subject: [PATCH 4/7] Update CHANGELOG.md --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77f1360..b8566ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bug fixes go here +## [1.2.0] - 2024-06-04 + +### :sparkles: Added + +- Adds support for passing custom app path through the `app-file` input +- Adds cdk-nag and identity pool alpha as dependencies + +### :pencil2: Changed + +- Bumps CDK dependency versions + ## [1.1.0] - 2023-10-10 ### :sparkles: Added From a2b12647e859a77a94835bf9a49a62916417cb66 Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 10:27:55 +0100 Subject: [PATCH 5/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4038c15..ee230e2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Currently, the action supports: | add-branch-suffix | boolean | no | false | Appends a commit hash to the Stack ID | | ephemeral | boolean | no | false | Destroys the Stack at the end of the Job | | parameters | string | no | "" | CfnParameters of the form `k1=v1 k2=v2 ...` | -| app-file | string | no | "app.py | Path to the CDK App file | +| app-file | string | no | app.py | Path to the CDK App file | ## Action Outputs From dc8e24bf77f5379b49288ee6eebf7fa3e4910d4b Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 10:29:06 +0100 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee230e2..0bb30b1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ jobs: id: deploy uses: rivelinrobotics/deploy-aws-cdk-stack@v1 with: + app-file: ./aws/app.py stack-id: MyCustomStack add-branch-suffix: true ephemeral: true @@ -53,7 +54,6 @@ jobs: Parameter1=Value1 Parameter2=Value2 Parameter3=Value3 - app_file: ./aws/app.py - name: Access Stack Output run: echo ${{ fromJSON(steps.deploy.outputs.stack-output).MyCustomValue }} ``` From eb20ef0b3f1980bac9310399da3050678f91377d Mon Sep 17 00:00:00 2001 From: Tom Noble Date: Tue, 4 Jun 2024 10:56:30 +0100 Subject: [PATCH 7/7] Fixes destroy script --- destroy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/destroy.sh b/destroy.sh index 2348e77..f9d99b2 100755 --- a/destroy.sh +++ b/destroy.sh @@ -2,7 +2,7 @@ STACK_ID=${1} ADD_STACK_SUFFIX=${2} -APP_FILE=${3} +APP_FILE=${4} FULL_STACK_ID=${STACK_ID} UNSCOPED_APP=${APP_FILE}.tmp CDK_PROJECT=/github/workspace