Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update cleanup script to correctly use assumed creds in child accounts #467

Merged
merged 1 commit into from
May 23, 2022

Conversation

alharris-at
Copy link
Contributor

@alharris-at alharris-at commented May 23, 2022

Description of changes

There are 2 keys changes in this PR, then a bunch of general cleanup.

  1. in configureAws which is called before searching for staleResources in child stacks, we were setting our aws creds to...
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
sessionToken: process.env.AWS_SESSION_TOKEN,
...(process.env.AWS_SESSION_TOKEN ? { sessionToken: process.env.AWS_SESSION_TOKEN } : {}),

despite passing in the accessKeyId, etc. So we were never actually using the assumed creds.

  1. inside the account->region nested loop we had some code like.
for (const region of AWS_REGIONS_TO_RUN_TESTS) {
  amplifyApps.push(...(await getAmplifyApps(region)));
  stacks.push(...(await getStacks(region)));
}

Because these are parallel network calls, I rewrote the loop to return a list of promises, then yield all promises at once. This could be taken a lot further, since we have nested awaits inside those top-level functions, but that'd require a more significant refactor of the code.

Issue #, if available

N/A, but CI workflows are failing w/ 'Too Many Buckets' or some related error.

Description of how you validated changes

Ran locally w/ my own API key for Circle, and verified the output made sense.

Checklist

  • PR description included

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@alharris-at alharris-at marked this pull request as ready for review May 23, 2022 17:29
@alharris-at alharris-at requested a review from a team May 23, 2022 17:29
@alharris-at alharris-at requested a review from a team as a code owner May 23, 2022 17:29
Copy link
Contributor

@sundersc sundersc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants