Skip to content

Commit

Permalink
Merge pull request #4 from observeinc/joao/secrets
Browse files Browse the repository at this point in the history
feat: synchronize github secrets to secretsmanager
  • Loading branch information
jta authored Apr 10, 2024
2 parents dbd133d + f5d3d65 commit 09b01e3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/tf-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ jobs:
role-session-name: ${{ github.sha }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Synchronize secrets
env:
SECRETS: ${{ toJSON(secrets) }}
shell: bash
run: |
LOCAL=`echo "$SECRETS" | jq 'with_entries(select(.key | startswith("X_")))'`
REMOTE=`aws secretsmanager get-secret-value --secret-id ${{ github.event.repository.name }} | jq -r .SecretString`
FILTERED=`echo ${REMOTE} | jq 'with_entries(select(.key | startswith("X_") | not))'`
MERGED=`echo ${LOCAL} ${REMOTE} | jq -s add`
if [[ "$MERGED" != "$REMOTE" ]]
then
aws secretsmanager put-secret-value --secret-id ${{ github.event.repository.name }} --secret-string="$MERGED"
fi
- name: Terraform Init
id: init
run: |
Expand Down Expand Up @@ -222,4 +236,4 @@ jobs:
fi
terraform apply "${apply_args[@]}" -auto-approve

0 comments on commit 09b01e3

Please sign in to comment.