-
Notifications
You must be signed in to change notification settings - Fork 60
fix(integ-runner): region is not passed to CDK App #949
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #949 +/- ##
==========================================
- Coverage 84.50% 84.47% -0.04%
==========================================
Files 71 71
Lines 10445 10445
Branches 1344 1344
==========================================
- Hits 8827 8823 -4
- Misses 1577 1581 +4
Partials 41 41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| force: argv.force as boolean, | ||
| dryRun: argv['dry-run'] as boolean, | ||
| disableUpdateWorkflow: argv['disable-update-workflow'] as boolean, | ||
| disableUpdateWorkflow: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change the default to true, but not always set it to true so it can be used in the future.
| private async validateRegion(asm: IReadableCloudAssembly) { | ||
| for (const stack of asm.cloudAssembly.stacksRecursively) { | ||
| if (stack.environment.region !== this.options.region && stack.environment.region !== UNKNOWN_REGION) { | ||
| throw new Error(`Stack ${stack.displayName} synthesizes for region ${stack.environment.region}, even though ${this.options.region} was requested. Please configure \`{ env: { region: process.env.CDK_DEFAULT_REGION, account: process.env.CDK_DEFAULT_ACCOUNT } }\`, or use no env at all. Do not hardcode a region or account.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this fail for cross-region integ tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it will. In fact cross-region integ tests won't work properly with an external system that imposes a region at all.
What do you suggest instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, we can throw a warning instead of an error so we don't make integ test workflows fail unnecessarily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmkay. My personal life philosophy is: no one looks at warnings. So that will do literally diddly squat.
But okay, I'll make it a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I share that philosophy too. Issue is that we currently have cross-region integ tests and this will block PR merges in aws-cdk whenever we update cross-region integ test snapshots.
|
I was told this is not a bug just a couple of months ago: #624 (comment) |
| force: argv.force as boolean, | ||
| dryRun: argv['dry-run'] as boolean, | ||
| disableUpdateWorkflow: argv['disable-update-workflow'] as boolean, | ||
| disableUpdateWorkflow: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a separate PR please, so we can have a separate discussion and a separate changelog entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split off to here: #951
The issue you just linked is about doing: What region should be bootstrapped? This PR is about |
When using the `toolkit-lib` deployment engine, the selected region was not being passed to the CDK app. In the old engine, we could set the `AWS_REGION` environment variable and the CDK CLI would respect that, but the toolkit lib was passing that environment variable directly to the CDK app which was not respecting that. Fix that by threading the region through as an explicit parameter and adding an override parameter to the `AwsCliCompatible` base credentials: we don't necessarily want to read this only from the INI files. Additionally: add a validation to make sure that the CDK app respects the region we are requesting. CDK integ tests should either not pass an environment, or read `$CDK_DEFAULT_REGION` to determine the current region. It was too easy to just override the region with a hardcoded one, but that breaks the integ runner's attempts to isolate tests across regions. Guard against that by validating.
4f099e9 to
a5226ac
Compare
### Reason for this change Integ runner does not deploy to the correct regions that have been set to be bootstrapped. ### Description of changes Updates the integ-runner version which fixes this bug. Fix is detailed in aws/aws-cdk-cli#949 As the new version changes the default CWD of integ tests, some integ tests had to be modified to use __dirname to lookup local assets files. ### Describe any new or updated permissions being added No new permissions are added. ### Description of how you validated changes Fix is confirmed with local fork run: https://github.com/Abogical/aws-cdk/actions/runs/19569552896/job/56039507543 ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

When using the
toolkit-libdeployment engine, the selected region was not being passed to the CDK app.In the old engine, we could set the
AWS_REGIONenvironment variable and the CDK CLI would respect that, but the toolkit lib was passing that environment variable directly to the CDK app which was not respecting that. Fix that by threading the region through as an explicit parameter and adding an override parameter to theAwsCliCompatiblebase credentials: we don't necessarily want to read this only from the INI files.Additionally: add a validation to make sure that the CDK app respects the region we are requesting. CDK integ tests should either not pass an environment, or read
$CDK_DEFAULT_REGIONto determine the current region. It was too easy to just override the region with a hardcoded one, but that breaks the integ runner's attempts to isolate tests across regions. Guard against that by validating.Also in this PR: disable the update workflow. I've lost 2 hours debugging why my deployment was failing with nonsenical values and the answer was: the checked-in snapshot was nonsensical, and the update workflow will first deploy the checked-in snapshot and only then deploy the current snapshot. Good idea, bad execution: if existing snapshots are not region-agnostic they are guaranteed to fail. We should probably resynthesize them from the previous git commit instead. Whatever it is, what we do right now doesn't work so I'm disabling it.
Fixes #
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license