feat!(vpc-import): Reimplement reference to a pre-existing VPC #2574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note
Need to consider the impact on these projects:
publicSubnets
toGuEc2App
privateSubnets
toGuEc2App
GuVpc.fromIdParameter
GuVpc.subnetsFromParameterFixedNumber
What does this change?
The current implementation of importing a VPC, via SSM Parameters, for use in an application makes reference to the AWS CDK method
scope.availabilityZones
. AWS CDK comments about this:That is, AWS CDK attempts to dynamically resolve the AZs by interrogating the account and storing values in the context file. If we don't configure AWS CDK with AWS credentials, attempts to reference a subnet results in the error:
This is very confusing!
We don't need to call
scope.availabilityZones
as we usually do not explicitly specify the AZ to place our resources. These changes reimplement how we reference a pre-existing VPC. The following have been replaced withGuVpcImport.fromSsmParameters
:GuVpc.fromIdParameter
GuVpc.subnetsFromParameter
For the most part, this should not impact any stacks as GuCDK's patterns have been updated. It is a breaking change, however, as this change includes a change to the CloudFormation parameter names.
How to test
See added and updated unit tests.
I've also tested these changes in guardian/cdk-playground#629.
How can we measure success?
More intuitive DX, with a reduction in confusing errors.
Have we considered potential risks?
We'd need to check the compatibility of these changes with those in #1566 and #2477.
Checklist
Footnotes
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. ↩
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? ↩