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

[ec2-vpc]: SubnetSelection with AZs with vpc contruct in same application #27540

Open
annguyen36 opened this issue Oct 14, 2023 · 2 comments
Open
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud documentation This is a problem with documentation. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@annguyen36
Copy link

Describe the issue

Hello team,

We identified an issue: the .selectSubnets() method doesn't function with availabilityZones when the VPC is within the same application, example snippet:

  const supportedAZs = ['us-east-1d', 'us-east-1a', 'us-east-1c'];
  const selectedSubnets = vpc.selectSubnets({
          availabilityZones: supportedAZs,
          subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS
      });

Upon verification, it's apparent that the AZ value acts as the TOKEN placeholder during the stack's synthesis, leading the above selectedSubnets to return empty. Notably, this operates correctly if the VPC is imported from an existing one.

Should this be intended behavior, might we request an update to the documentation, specifically regarding the availabilityZones parameter within the SubnetSelection interface, to prevent future confusion?

Links

e

@annguyen36 annguyen36 added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Oct 14, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Oct 14, 2023
@pahud
Copy link
Contributor

pahud commented Oct 17, 2023

const vpc = new ec2.Vpc(this, 'Vpc', { maxAzs: 3 });
const supportedAZs = ['us-east-1d', 'us-east-1a', 'us-east-1c'];
const selectedSubnets = vpc.selectSubnets({
		availabilityZones: supportedAZs,
		subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS
});

new CfnOutput(this, 'selectedSubnets', { value: selectedSubnets.subnetIds.join(',')})

If you create a new VPC in the app, you will not now the selected subnetIds until deployment so you will only get the tokens.

Can you specify which document statement should be improved?

@pahud pahud added p2 effort/small Small work item – less than a day of effort response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2023
@annguyen36
Copy link
Author

Hi pahud,
Thanks for confirmation.
I would suggest add this in the availibilityZones prop description in this doc https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html#availabilityzones

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 17, 2023
@ashishdhingra ashishdhingra added the feature-request A feature should be added or improved. label Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud documentation This is a problem with documentation. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

3 participants