Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
fix: add error handling for when SSM secrets cannot be retrieved
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinpinto committed Sep 11, 2020
1 parent 59093c3 commit 8c2a9ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/aws-ssm-secrets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ jobs:
role-to-assume: "arn:aws:iam::111111111111:role/build-and-deploy-website"
role-duration-seconds: 1800 # 30 mins

- uses: "marvinpinto/action-inject-ssm-secrets@v1"
- uses: "marvinpinto/action-inject-ssm-secrets@latest"
with:
ssm_parameter: "/build-secrets/${{ env.BUILD_STAGE }}/cloudflare-account-id"
env_variable_name: "cloudflare_account_id"

- uses: "marvinpinto/action-inject-ssm-secrets@v1"
- uses: "marvinpinto/action-inject-ssm-secrets@latest"
with:
ssm_parameter: "/build-secrets/${{ env.BUILD_STAGE }}/cloudflare-api-token"
env_variable_name: "cloudflare_api_token"
Expand Down
18 changes: 12 additions & 6 deletions packages/aws-ssm-secrets/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@ export const main = async () => {
const ssm = new SSM();
core.startGroup('Injecting secret environment variables');

const result = await ssm
.getParameter({
Name: actionParam.ssmParameter,
WithDecryption: true, // NOTE: this flag is ignored for String and StringList parameter types
})
.promise();
let result;
try {
result = await ssm
.getParameter({
Name: actionParam.ssmParameter,
WithDecryption: true, // NOTE: this flag is ignored for String and StringList parameter types
})
.promise();
} catch (error) /* istanbul ignore next */ {
core.setFailed(error.message);
throw error;
}

const envVar = actionParam.envVariable.toUpperCase();
const secret = result?.Parameter?.Value;
Expand Down

0 comments on commit 8c2a9ec

Please sign in to comment.