Skip to content

Commit

Permalink
fix: creds passing
Browse files Browse the repository at this point in the history
  • Loading branch information
the-technat committed Dec 13, 2023
1 parent f071517 commit 9a621f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/create-eks-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
env:
STATE_BUCKET: "grapes-state"
STATE_BUCKET_REGION: "eu-west-1"
outputs:
output1: ${{ steps.aws_user.outputs.cluster_access_key }}
output2: ${{ steps.aws_user.outputs.cluster_secret_key }}
steps:
- uses: actions/checkout@v4
- name: configure aws credentials
Expand Down Expand Up @@ -81,14 +84,14 @@ jobs:
aws iam create-user --user-name ${{ github.event.inputs.name }}
aws iam attach-user-policy --policy-arn "arn:aws:iam::aws:policy/AdministratorAccess" --user-name ${{ github.event.inputs.name }}
aws iam create-access-key --user-name ${{ github.event.inputs.name }} --output=json > output.json
echo 'cluster_access_key=$(cat output.json | jq '.AccessKey.AccessKeyId' |tr -d "\"")' >> $GITHUB_OUTPUT
echo 'cluster_secret_key=$(cat output.json | jq '.AccessKey.SecretAccessKey' |tr -d "\"")' >> $GITHUB_OUTPUT
echo cluster_access_key=$(cat output.json | jq '.AccessKey.AccessKeyId' |tr -d "\"") >> $GITHUB_OUTPUT
echo cluster_secret_key=$(cat output.json | jq '.AccessKey.SecretAccessKey' |tr -d "\"") >> $GITHUB_OUTPUT
deploy:
runs-on: ubuntu-latest
needs: prepare
env:
AWS_ACCESS_KEY_ID: "${{ needs.prepare.aws_user.outputs.cluster_access_key }}"
AWS_SECRET_ACCESS_KEY: "${{ needs.prepare.aws_user.outputs.cluster_secret_key }}"
AWS_ACCESS_KEY_ID: "${{ needs.prepare.outputs.cluster_access_key }}"
AWS_SECRET_ACCESS_KEY: "${{ needs.prepare.outputs.cluster_secret_key }}"
AWS_REGION: "${{ github.event.inputs.region }}"
STATE_BUCKET: "grapes-state"
STATE_BUCKET_REGION: "eu-west-1"
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/delete-eks-terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
permissions:
id-token: write
contents: read
outputs:
output1: ${{ steps.aws_user.outputs.cluster_access_key }}
output2: ${{ steps.aws_user.outputs.cluster_secret_key }}
steps:
- uses: actions/checkout@v4
- name: configure aws credentials
Expand All @@ -23,6 +26,7 @@ jobs:
role-session-name: grapes
aws-region: eu-central-1 # doesn't matter for IAM
- name: Rotate credentials for cluster user
id: aws_user
run: |
aws iam create-access-key --user-name ${{ github.event.inputs.name }} --output=json > output.json
echo 'cluster_access_key=$(cat output.json | jq '.AccessKey.AccessKeyId' |tr -d "\"")' >> $GITHUB_OUTPUT
Expand All @@ -32,8 +36,8 @@ jobs:
needs: reprepare
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: "${{ needs.prepare.aws_user.outputs.cluster_access_key }}"
AWS_SECRET_ACCESS_KEY: "${{ needs.prepare.aws_user.outputs.cluster_secret_key }}"
AWS_ACCESS_KEY_ID: "${{ needs.reprepare.aws_user.outputs.cluster_access_key }}"
AWS_SECRET_ACCESS_KEY: "${{ needs.reprepare.aws_user.outputs.cluster_secret_key }}"
AWS_REGION: "${{ github.event.inputs.region }}"
STATE_BUCKET: "grapes-state"
STATE_BUCKET_REGION: "eu-west-1"
Expand Down

0 comments on commit 9a621f4

Please sign in to comment.