Skip to content

Commit

Permalink
Use multiple accounts (#1879)
Browse files Browse the repository at this point in the history
* use accounts in e2e cleanup

* health checks

* try this

* try this

* why ?

* try this

* try this

* try action

* Revert "try action"

This reverts commit e54ddd7.
  • Loading branch information
sobolk authored Aug 16, 2024
1 parent 4f75249 commit d755f74
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/e2e_resource_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
fail-fast: false
matrix:
region: [us-west-2, us-east-1, ca-central-1, eu-central-1]
testAccount: ${{ fromJson(vars.E2E_TEST_ACCOUNTS) }}
env:
AWS_REGION: ${{ matrix.region }}
steps:
Expand All @@ -27,7 +28,7 @@ jobs:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ secrets.E2E_RESOURCE_CLEANUP_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ matrix.testAccount }}:role/e2e-resource-cleanup
aws-region: ${{ matrix.region }}
- name: Run E2E resource cleanup
run: npm run e2e:cleanup-resources
50 changes: 40 additions & 10 deletions .github/workflows/health_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,22 @@ jobs:
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # version 4.1.4
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_build_cache
- name: Select E2E test account
id: selectE2EAccount
shell: bash
run: echo "e2e_test_account_number=$(npx tsx scripts/select_e2e_test_account.ts)" >> "$GITHUB_OUTPUT"
env:
E2E_TEST_ACCOUNTS: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ secrets.E2E_TOOLING_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-test-tooling
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ secrets.E2E_RUNNER_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-execution
aws-region: us-west-2
- name: Run e2e iam access drift test
run: npm run test:dir packages/integration-tests/lib/test-e2e/iam_access_drift.test.js
Expand Down Expand Up @@ -249,16 +255,22 @@ jobs:
node-version: ${{ matrix.node-version }}
- uses: ./.github/actions/restore_build_cache
- run: cd packages/cli && npm link
- name: Select E2E test account
id: selectE2EAccount
shell: bash
run: echo "e2e_test_account_number=$(npx tsx scripts/select_e2e_test_account.ts)" >> "$GITHUB_OUTPUT"
env:
E2E_TEST_ACCOUNTS: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ secrets.E2E_TOOLING_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-test-tooling
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ secrets.E2E_RUNNER_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-execution
aws-region: us-west-2
- name: Run e2e deployment tests
run: npm run test:dir packages/integration-tests/lib/test-e2e/deployment.test.js
Expand Down Expand Up @@ -292,16 +304,22 @@ jobs:
node-version: ${{ matrix.node-version }}
- uses: ./.github/actions/restore_build_cache
- run: cd packages/cli && npm link
- name: Select E2E test account
id: selectE2EAccount
shell: bash
run: echo "e2e_test_account_number=$(npx tsx scripts/select_e2e_test_account.ts)" >> "$GITHUB_OUTPUT"
env:
E2E_TEST_ACCOUNTS: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ secrets.E2E_TOOLING_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-test-tooling
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ secrets.E2E_RUNNER_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-execution
aws-region: us-west-2
- name: Run e2e sandbox tests
run: npm run test:dir packages/integration-tests/lib/test-e2e/sandbox.test.js
Expand All @@ -321,16 +339,22 @@ jobs:
- uses: ./.github/actions/setup_node
- uses: ./.github/actions/restore_build_cache
- run: cd packages/cli && npm link
- name: Select E2E test account
id: selectE2EAccount
shell: bash
run: echo "e2e_test_account_number=$(npx tsx scripts/select_e2e_test_account.ts)" >> "$GITHUB_OUTPUT"
env:
E2E_TEST_ACCOUNTS: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ secrets.E2E_TOOLING_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-test-tooling
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ secrets.E2E_RUNNER_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-execution
aws-region: us-west-2
- name: Run e2e backend output tests
run: npm run test:dir packages/integration-tests/lib/test-e2e/backend_output.test.js
Expand Down Expand Up @@ -391,16 +415,22 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Restore Build Cache
uses: ./.github/actions/restore_build_cache
- name: Select E2E test account
id: selectE2EAccount
shell: bash
run: echo "e2e_test_account_number=$(npx tsx scripts/select_e2e_test_account.ts)" >> "$GITHUB_OUTPUT"
env:
E2E_TEST_ACCOUNTS: ${{ vars.E2E_TEST_ACCOUNTS }}
- name: Configure test tooling credentials
uses: ./.github/actions/setup_profile
with:
role-to-assume: ${{ secrets.E2E_TOOLING_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-test-tooling
aws-region: us-west-2
profile-name: e2e-tooling
- name: Configure test execution credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # version 4.0.2
with:
role-to-assume: ${{ secrets.E2E_RUNNER_ROLE_ARN }}
role-to-assume: arn:aws:iam::${{ steps.selectE2EAccount.outputs.e2e_test_account_number }}:role/e2e-execution
aws-region: us-west-2
- name: Run E2E flow tests with ${{ matrix.pkg-manager }}
shell: bash
Expand Down
11 changes: 11 additions & 0 deletions scripts/select_e2e_test_account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
if (!process.env.E2E_TEST_ACCOUNTS) {
throw new Error(
'E2E_TEST_ACCOUNTS environment variable must be defined and contain array of strings with account numbers'
);
}

const accounts = JSON.parse(process.env.E2E_TEST_ACCOUNTS);

const selectedAccount = accounts[Math.floor(Math.random() * accounts.length)];

console.log(selectedAccount);

0 comments on commit d755f74

Please sign in to comment.