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

vpc construct: only try setting context if unset #2438

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

andrew-nowak
Copy link
Member

What does this change?

currently a single stack cannot create multiple vpcs, as each will try to set the context itself, and the subsequent creations will throw errors like

Cannot set context after children have been added: MyVpc

Instead, only attempt to set the context if it is unset

How to test

Run the provided unit test

How can we measure success?

Stacks in the account setup repo can succeed even if one account attempts to create two "new VPCs".

Have we considered potential risks?

I don't really understand this error, I may have missed a more correct fix for this situation.

Checklist

  • I have listed any breaking changes, along with a migration path 1
  • I have updated the documentation as required for the described changes 2

Footnotes

  1. Consider whether this is something that will mean changes to projects that have already been migrated, or to the CDK CLI tool. If changes are required, consider adding a checklist here and/or linking to related PRs.

  2. If you are adding a new construct or pattern, has new documentation been added? If you are amending defaults or changing behaviour, are the existing docs still valid?

currently a single stack cannot create multiple vpcs, as each will try
to set the context itself, and the subsequent creations will throw
errors like

  Cannot set context after children have been added: MyVpc
@andrew-nowak andrew-nowak requested a review from a team as a code owner September 2, 2024 15:46
Copy link

changeset-bot bot commented Sep 2, 2024

🦋 Changeset detected

Latest commit: 8e8a20f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@guardian/cdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"eu-west-1b",
"eu-west-1c",
]);
const contextKey = `availability-zones:account=${account}:region=eu-west-1`;
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR necessarily, but I wonder why the region has been hard-coded here, rather than this.region?

@andrew-nowak andrew-nowak merged commit f1bcb7b into main Sep 3, 2024
4 checks passed
@andrew-nowak andrew-nowak deleted the an/one-stack-multiple-vpcs branch September 3, 2024 17:03
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