Skip to content

Commit da54d84

Browse files
committed
re-add static integ test rewrite
1 parent 9d1c420 commit da54d84

1 file changed

Lines changed: 37 additions & 6 deletions

File tree

.github/workflows/tests-integ-release.yml

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,59 @@ jobs:
3434
#can cut this test out if it's not necessary
3535
static_assumeRole:
3636
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.pull_request.user.login == 'aws-sdk-osds' && github.repository == 'aws-actions/configure-aws-credentials') }}
37+
permissions:
38+
id-token: write
3739
strategy:
3840
fail-fast: false
3941
matrix:
4042
os: [windows-latest, ubuntu-latest, macos-latest]
4143
runs-on: ${{ matrix.os }}
44+
defaults:
45+
run:
46+
shell: bash
4247
name: Static IAM creds test
4348
steps:
4449
- name: checkout
4550
uses: actions/checkout@v5
4651
with:
4752
fetch-depth: 0
4853
persist-credentials: false
49-
- name: Configure AWS credentials
54+
- name: assume creator Role
5055
uses: ./
5156
with:
5257
aws-region: us-west-2
53-
aws-access-key-id: ${{ secrets.STATIC_ak_id }}
54-
aws-secret-access-key: ${{ secrets.STATIC_secret_ak }}
55-
role-to-assume: ${{ secrets.STATIC_role }}
56-
- name: Get Caller Identity
58+
role-to-assume: ${{ secrets.STATIC_USER_CREATION_ROLE }}
59+
- name: create and mask access key
60+
id: create-key
61+
run: |
62+
AK_OUTPUT=$(aws iam create-access-key --user-name integ-test-static-user-${{ runner.os }})
63+
AK_ID=$(echo $AK_OUTPUT | jq -r '.AccessKey.AccessKeyId')
64+
SECRET_AK=$(echo $AK_OUTPUT | jq -r '.AccessKey.SecretAccessKey')
65+
echo "::add-mask::$AK_ID"
66+
echo "::add-mask::$SECRET_AK"
67+
echo "STATIC_ACCESS_KEY_ID=$AK_ID" >> $GITHUB_OUTPUT
68+
echo "STATIC_SECRET_ACCESS_KEY=$SECRET_AK" >> $GITHUB_OUTPUT
69+
- name: sleep so key can propagate
70+
run: sleep 30
71+
- name: assume role with static creds
72+
uses: ./
73+
with:
74+
aws-region: us-west-2
75+
role-to-assume: ${{ secrets.STATIC_TEST_TARGET_ROLE }}
76+
aws-access-key-id: ${{ steps.create-key.outputs.STATIC_ACCESS_KEY_ID }}
77+
aws-secret-access-key: ${{ steps.create-key.outputs.STATIC_SECRET_ACCESS_KEY }}
78+
- name: check account
79+
run: aws sts get-caller-identity
80+
- name: log back into creator role
81+
if: success() || failure()
82+
uses: ./
83+
with:
84+
aws-region: us-west-2
85+
role-to-assume: ${{ secrets.STATIC_USER_CREATION_ROLE }}
86+
- name: delete access key
87+
if: success() || failure()
5788
run: |
58-
aws sts get-caller-identity
89+
aws iam delete-access-key --user-name integ-test-static-user-${{ runner.os }} --access-key-id ${{ steps.create-key.outputs.STATIC_ACCESS_KEY_ID }}
5990
6091
role_chaining:
6192
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.pull_request.user.login == 'aws-sdk-osds' && github.repository == 'aws-actions/configure-aws-credentials') }}

0 commit comments

Comments
 (0)