Skip to content

Commit

Permalink
Adding redaction to plan and apply workflows (#1082)
Browse files Browse the repository at this point in the history
* Adding redaction to plan and apply workflows

* changed file permissions

* path changed
  • Loading branch information
markgov authored Jan 24, 2025
1 parent a6d88fb commit 1735331
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/management-account-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
continue-on-error: true
- run: terraform init
- run: terraform validate -no-color
- run: terraform plan -no-color
- run: terraform apply -auto-approve
- run: terraform plan -no-color | ../../scripts/redaction.sh
- run: terraform apply -auto-approve | ../../scripts/redaction.sh
if: github.event.ref == 'refs/heads/main'

- name: Slack failure notification
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/management-account-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
continue-on-error: true
- run: terraform init
- run: terraform validate -no-color
- run: terraform plan -no-color
- run: terraform plan -no-color | ../../scripts/redaction.sh

4 changes: 2 additions & 2 deletions .github/workflows/organisation-security-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
continue-on-error: true
- run: terraform init
- run: terraform validate -no-color
- run: terraform plan -no-color
- run: terraform apply -auto-approve
- run: terraform plan -no-color | ../../scripts/redaction.sh
- run: terraform apply -auto-approve | ../../scripts/redaction.sh
if: github.event.ref == 'refs/heads/main'

- name: Slack failure notification
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/organisation-security-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ jobs:
continue-on-error: true
- run: terraform init
- run: terraform validate -no-color
- run: terraform plan -no-color

- run: terraform plan -no-color | ../../scripts/redaction.sh
10 changes: 10 additions & 0 deletions scripts/redaction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Based on: https://github.com/ministryofjustice/opg-org-infra/blob/main/scripts/redact_output.sh

sed -u -E \
-e "s/AWS_SECRET_ACCESS_KEY=.*/AWS_SECRET_ACCESS_KEY=<REDACTED>/g" \
-e "s/AWS_ACCESS_KEY_ID=.*/AWS_ACCESS_KEY_ID=<REDACTED>/g" \
-e "s/\$(AWS_SECRET_ACCESS_KEY)=.*/\$(AWS_SECRET_ACCESS_KEY)=<REDACTED>/g" \
-e "s/\$(AWS_ACCESS_KEY_ID)=.*/\$(AWS_ACCESS_KEY_ID)=<REDACTED>/g" \
-e "s/\[id=[^]]*\]/\[id=<REDACTED>]/g" \
-e "s/::[0-9]{12}:/::REDACTED:/g" \
-e "s/:[0-9]{12}:/:REDACTED:/g"

0 comments on commit 1735331

Please sign in to comment.