From d95137844faf7c9709e3412642be53c7762f48f7 Mon Sep 17 00:00:00 2001 From: IbrahimJassat Date: Fri, 30 Oct 2026 11:41:58 +0000 Subject: [PATCH 1/6] To allow the overwrites a single AWS Systems Manager Parameter Store value --- .github/workflows/update-ssm-parameter.yaml | 47 +++++++++++++++++++++ README.md | 33 +++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/update-ssm-parameter.yaml diff --git a/.github/workflows/update-ssm-parameter.yaml b/.github/workflows/update-ssm-parameter.yaml new file mode 100644 index 0000000..97647ba --- /dev/null +++ b/.github/workflows/update-ssm-parameter.yaml @@ -0,0 +1,47 @@ +name: Update SSM parameter action + +on: + workflow_call: + inputs: + environment: + required: true + type: string + parameter-name: + description: Full name of the Parameter Store parameter + required: true + type: string + parameter-type: + required: false + type: string + default: String + secrets: + AWS_ACCOUNT: + required: true + AWS_REGION: + required: true + AWS_ROLE_TO_ASSUME_ARN: + required: true + PARAMETER_VALUE: + required: true + +jobs: + update: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + permissions: + id-token: write + steps: + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN }} + role-session-name: GithubActionsSession + aws-region: ${{ secrets.AWS_REGION }} + - name: Update SSM parameter + env: + PARAMETER_NAME: ${{ inputs.parameter-name }} + PARAMETER_TYPE: ${{ inputs.parameter-type }} + PARAMETER_VALUE: ${{ secrets.PARAMETER_VALUE }} + run: | + aws ssm put-parameter --name "$PARAMETER_NAME" --value "$PARAMETER_VALUE" --type "$PARAMETER_TYPE" --overwrite + echo "Updated $PARAMETER_NAME" diff --git a/README.md b/README.md index fac8662..6cbadad 100644 --- a/README.md +++ b/README.md @@ -367,6 +367,39 @@ The upload-to-s3 action with a matrix strategy defined: In the s3 bucket, the objects have been uploaded to the specified location: `backend/lambdaA/feature-new-frontend.zip` and `backend/lambdaB/feature-new-frontend.zip`. +## The `update-ssm-parameter.yaml` workflow has the following steps: + +This workflow overwrites a single AWS Systems Manager Parameter Store value, typically from a GitHub secret or variable. + +1. Arguments + - `environment`: The GitHub environment to run in. + - `parameter-name`: Full name of the parameter. + - `parameter-type`: `String`. Default is `String`. + - secrets: + - `AWS_ACCOUNT`: the account number for the aws environment the archive is to be uploaded to. + - `AWS_REGION`: the account region for the aws environment the archive is to be upgraded to. It's easier to maintain if this is only set in one place. + - `AWS_ROLE_TO_ASSUME_ARN`: The ARN for the role assume to run `ssm:PutParameter`. + - `PARAMETER_VALUE`: The value to store. + +2. Steps + - Configure aws credentials + - Update SSM parameter with `aws ssm put-parameter --overwrite`. + +```YAML + update-ssm-parameter: + uses: dvsa/.github/.github/workflows/update-ssm-parameter.yaml@v7 + with: + environment: nonprod + parameter-name: /project/nonprod/client-secret + permissions: + id-token: write + secrets: + AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} + AWS_REGION: ${{ secrets.AWS_REGION }} + AWS_ROLE_TO_ASSUME_ARN: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN }} + PARAMETER_VALUE: ${{ secrets.CLIENT_SECRET }} +``` + ## The Java `java-snyk-update.yaml` workflow has the following steps: This workflow can be used to update a Java project within Snyk, typically invoked after a merge has been approved. From 9207200054e995bc442565a03e72970b42201076 Mon Sep 17 00:00:00 2001 From: IbrahimJassat Date: Mon, 2 Nov 2026 14:25:38 +0000 Subject: [PATCH 2/6] updated as the var is in nft env --- .github/workflows/update-ssm-parameter.yaml | 13 ++++++++++--- README.md | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-ssm-parameter.yaml b/.github/workflows/update-ssm-parameter.yaml index 97647ba..2b8f4a7 100644 --- a/.github/workflows/update-ssm-parameter.yaml +++ b/.github/workflows/update-ssm-parameter.yaml @@ -14,9 +14,12 @@ on: required: false type: string default: String + parameter-value-variable: + description: Name of an environment variable holding the value. Used instead of the PARAMETER_VALUE secret when set + required: false + type: string + default: '' secrets: - AWS_ACCOUNT: - required: true AWS_REGION: required: true AWS_ROLE_TO_ASSUME_ARN: @@ -41,7 +44,11 @@ jobs: env: PARAMETER_NAME: ${{ inputs.parameter-name }} PARAMETER_TYPE: ${{ inputs.parameter-type }} - PARAMETER_VALUE: ${{ secrets.PARAMETER_VALUE }} + PARAMETER_VALUE: ${{ inputs.parameter-value-variable != '' && vars[inputs.parameter-value-variable] || secrets.PARAMETER_VALUE }} run: | + if [[ -z "$PARAMETER_VALUE" ]]; then + echo "::error::No value supplied for $PARAMETER_NAME" + exit 1 + fi aws ssm put-parameter --name "$PARAMETER_NAME" --value "$PARAMETER_VALUE" --type "$PARAMETER_TYPE" --overwrite echo "Updated $PARAMETER_NAME" diff --git a/README.md b/README.md index 6cbadad..d781fca 100644 --- a/README.md +++ b/README.md @@ -379,7 +379,8 @@ This workflow overwrites a single AWS Systems Manager Parameter Store value, typ - `AWS_ACCOUNT`: the account number for the aws environment the archive is to be uploaded to. - `AWS_REGION`: the account region for the aws environment the archive is to be upgraded to. It's easier to maintain if this is only set in one place. - `AWS_ROLE_TO_ASSUME_ARN`: The ARN for the role assume to run `ssm:PutParameter`. - - `PARAMETER_VALUE`: The value to store. + - `PARAMETER_VALUE`: The value to store. Optional when `parameter-value-variable` is set. + - `parameter-value-variable`: Optional name of a variable in the GitHub environment to use as the value instead of the secret. 2. Steps - Configure aws credentials From a75e1d0d30bb052d20456d02b6a21f8bcb0943f3 Mon Sep 17 00:00:00 2001 From: IbrahimJassat Date: Mon, 2 Nov 2026 15:53:43 +0000 Subject: [PATCH 3/6] changes made --- .github/workflows/update-ssm-parameter.yaml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-ssm-parameter.yaml b/.github/workflows/update-ssm-parameter.yaml index 2b8f4a7..d2ada8a 100644 --- a/.github/workflows/update-ssm-parameter.yaml +++ b/.github/workflows/update-ssm-parameter.yaml @@ -19,13 +19,18 @@ on: required: false type: string default: '' + role-name: + description: IAM role name to assume in the environment's account (AWS_ACCOUNT_ID variable). Used when the AWS_ROLE_TO_ASSUME_ARN secret is not set + required: false + type: string + default: '' secrets: AWS_REGION: - required: true + required: false AWS_ROLE_TO_ASSUME_ARN: - required: true + required: false PARAMETER_VALUE: - required: true + required: false jobs: update: @@ -37,9 +42,9 @@ jobs: - name: Configure aws credentials uses: aws-actions/configure-aws-credentials@v6 with: - role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN }} + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN || format('arn:aws:iam::{0}:role/{1}', vars.AWS_ACCOUNT_ID, inputs.role-name) }} role-session-name: GithubActionsSession - aws-region: ${{ secrets.AWS_REGION }} + aws-region: ${{ secrets.AWS_REGION || vars.AWS_REGION }} - name: Update SSM parameter env: PARAMETER_NAME: ${{ inputs.parameter-name }} From 4f65d78159471d4e3bfcc1e7e839a1c0a4378afd Mon Sep 17 00:00:00 2001 From: IbrahimJassat Date: Tue, 3 Nov 2026 12:41:30 +0000 Subject: [PATCH 4/6] added workflow to restart ecs containers --- .github/workflows/restart-ecs-containers.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/restart-ecs-containers.yaml diff --git a/.github/workflows/restart-ecs-containers.yaml b/.github/workflows/restart-ecs-containers.yaml new file mode 100644 index 0000000..75e2e43 --- /dev/null +++ b/.github/workflows/restart-ecs-containers.yaml @@ -0,0 +1,54 @@ +name: Restart ECS Containers + +run-name: Restart ECS Containers - ${{ inputs.environment }} + +permissions: + id-token: write + contents: read + +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to restart' + required: true + type: choice + options: + - dev01 + - int + - nft + - accept + - preprod + default: nft + workflow_call: + inputs: + environment: + required: true + type: string + +jobs: + restart-ecs: + name: Restart ECS Containers - ${{ inputs.environment }} + runs-on: ubuntu-latest + environment: + name: ${{ inputs.environment }} + deployment: false + env: + ECS_CLUSTER: cpms-${{ inputs.environment }}-base-api + ECS_SERVICE: cpms-${{ inputs.environment }}-base-api-service + steps: + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ vars.AWS_BATCH_ROLE_NAME }} + role-session-name: GithubActionsSession + aws-region: ${{ vars.AWS_REGION }} + + - name: Force new ECS deployment + run: | + aws ecs update-service \ + --cluster "$ECS_CLUSTER" \ + --service "$ECS_SERVICE" \ + --force-new-deployment + echo "Restarting $ECS_SERVICE" + aws ecs wait services-stable --cluster "$ECS_CLUSTER" --services "$ECS_SERVICE" From 172c7bbb671944f91f9088e7609e59c98a941e52 Mon Sep 17 00:00:00 2001 From: IbrahimJassat Date: Fri, 6 Nov 2026 14:36:13 +0000 Subject: [PATCH 5/6] changes made after code review --- .github/workflows/restart-ecs-containers.yaml | 34 +++++++++---------- .github/workflows/update-ssm-parameter.yaml | 17 ++++------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/.github/workflows/restart-ecs-containers.yaml b/.github/workflows/restart-ecs-containers.yaml index 75e2e43..56a485d 100644 --- a/.github/workflows/restart-ecs-containers.yaml +++ b/.github/workflows/restart-ecs-containers.yaml @@ -7,24 +7,24 @@ permissions: contents: read on: - workflow_dispatch: - inputs: - environment: - description: 'Environment to restart' - required: true - type: choice - options: - - dev01 - - int - - nft - - accept - - preprod - default: nft workflow_call: inputs: environment: required: true type: string + cluster: + description: 'ECS cluster to restart' + required: true + type: string + service: + description: 'ECS service to restart' + required: true + type: string + secrets: + AWS_REGION: + required: true + AWS_ROLE_TO_ASSUME_ARN: + required: true jobs: restart-ecs: @@ -34,15 +34,15 @@ jobs: name: ${{ inputs.environment }} deployment: false env: - ECS_CLUSTER: cpms-${{ inputs.environment }}-base-api - ECS_SERVICE: cpms-${{ inputs.environment }}-base-api-service + ECS_CLUSTER: ${{ inputs.cluster }} + ECS_SERVICE: ${{ inputs.service }} steps: - name: Configure aws credentials uses: aws-actions/configure-aws-credentials@v6 with: - role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/${{ vars.AWS_BATCH_ROLE_NAME }} + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN }} role-session-name: GithubActionsSession - aws-region: ${{ vars.AWS_REGION }} + aws-region: ${{ secrets.AWS_REGION }} - name: Force new ECS deployment run: | diff --git a/.github/workflows/update-ssm-parameter.yaml b/.github/workflows/update-ssm-parameter.yaml index d2ada8a..01bcbf9 100644 --- a/.github/workflows/update-ssm-parameter.yaml +++ b/.github/workflows/update-ssm-parameter.yaml @@ -14,11 +14,6 @@ on: required: false type: string default: String - parameter-value-variable: - description: Name of an environment variable holding the value. Used instead of the PARAMETER_VALUE secret when set - required: false - type: string - default: '' role-name: description: IAM role name to assume in the environment's account (AWS_ACCOUNT_ID variable). Used when the AWS_ROLE_TO_ASSUME_ARN secret is not set required: false @@ -26,11 +21,11 @@ on: default: '' secrets: AWS_REGION: - required: false + required: true AWS_ROLE_TO_ASSUME_ARN: - required: false + required: true PARAMETER_VALUE: - required: false + required: true jobs: update: @@ -42,14 +37,14 @@ jobs: - name: Configure aws credentials uses: aws-actions/configure-aws-credentials@v6 with: - role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN || format('arn:aws:iam::{0}:role/{1}', vars.AWS_ACCOUNT_ID, inputs.role-name) }} + role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN }} role-session-name: GithubActionsSession - aws-region: ${{ secrets.AWS_REGION || vars.AWS_REGION }} + aws-region: ${{ secrets.AWS_REGION }} - name: Update SSM parameter env: PARAMETER_NAME: ${{ inputs.parameter-name }} PARAMETER_TYPE: ${{ inputs.parameter-type }} - PARAMETER_VALUE: ${{ inputs.parameter-value-variable != '' && vars[inputs.parameter-value-variable] || secrets.PARAMETER_VALUE }} + PARAMETER_VALUE: ${{ secrets.PARAMETER_VALUE }} run: | if [[ -z "$PARAMETER_VALUE" ]]; then echo "::error::No value supplied for $PARAMETER_NAME" From cd257313c268717e39301f59a4186cdd7e390563 Mon Sep 17 00:00:00 2001 From: IbrahimJassat Date: Mon, 9 Nov 2026 09:03:41 +0000 Subject: [PATCH 6/6] changes after code review --- .github/workflows/update-ssm-parameter.yaml | 5 ----- README.md | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/update-ssm-parameter.yaml b/.github/workflows/update-ssm-parameter.yaml index 01bcbf9..9f8dbfb 100644 --- a/.github/workflows/update-ssm-parameter.yaml +++ b/.github/workflows/update-ssm-parameter.yaml @@ -14,11 +14,6 @@ on: required: false type: string default: String - role-name: - description: IAM role name to assume in the environment's account (AWS_ACCOUNT_ID variable). Used when the AWS_ROLE_TO_ASSUME_ARN secret is not set - required: false - type: string - default: '' secrets: AWS_REGION: required: true diff --git a/README.md b/README.md index d781fca..2caf044 100644 --- a/README.md +++ b/README.md @@ -376,11 +376,9 @@ This workflow overwrites a single AWS Systems Manager Parameter Store value, typ - `parameter-name`: Full name of the parameter. - `parameter-type`: `String`. Default is `String`. - secrets: - - `AWS_ACCOUNT`: the account number for the aws environment the archive is to be uploaded to. - `AWS_REGION`: the account region for the aws environment the archive is to be upgraded to. It's easier to maintain if this is only set in one place. - `AWS_ROLE_TO_ASSUME_ARN`: The ARN for the role assume to run `ssm:PutParameter`. - - `PARAMETER_VALUE`: The value to store. Optional when `parameter-value-variable` is set. - - `parameter-value-variable`: Optional name of a variable in the GitHub environment to use as the value instead of the secret. + - `PARAMETER_VALUE`: The value to store. 2. Steps - Configure aws credentials @@ -395,7 +393,6 @@ This workflow overwrites a single AWS Systems Manager Parameter Store value, typ permissions: id-token: write secrets: - AWS_ACCOUNT: ${{ secrets.AWS_ACCOUNT }} AWS_REGION: ${{ secrets.AWS_REGION }} AWS_ROLE_TO_ASSUME_ARN: ${{ secrets.AWS_ROLE_TO_ASSUME_ARN }} PARAMETER_VALUE: ${{ secrets.CLIENT_SECRET }}