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): (max_azs=3 does not take effect) #30732

Closed
syangdh opened this issue Jul 2, 2024 · 4 comments
Closed

(ec2.Vpc): (max_azs=3 does not take effect) #30732

syangdh opened this issue Jul 2, 2024 · 4 comments
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@syangdh
Copy link

syangdh commented Jul 2, 2024

Describe the bug

I am trying to create a VPC with 3 AZs, but it turns out it only used 2 AZ, i.e., only have 6 subnets instead of 9 subnets

class VPCStack(core.Stack):

    def __init__(self, scope: Construct, id: str, environment: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        self.vpc = ec2.Vpc(self, "SharedVPC",
            ip_addresses=ec2.IpAddresses.cidr("10.0.0.0/16"),
            max_azs=3,
            nat_gateways = 1,
            subnet_configuration=[
                ec2.SubnetConfiguration(
                    subnet_type=ec2.SubnetType.PUBLIC,
                    name="Ingress",
                    cidr_mask=24
                ),
                ec2.SubnetConfiguration(
                    subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS,
                    name="Application",
                    cidr_mask=24
                ),
                ec2.SubnetConfiguration(
                    subnet_type=ec2.SubnetType.PRIVATE_ISOLATED,
                    name="Database",
                    cidr_mask=28
                )
            ]
        )

Expected Behavior

It should have created 9 subnets, but instead it created 6 subnets (My region is us-west-2)

Current Behavior

only 2 Az were used for the subnet creation

Reproduction Steps

Code is posted above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.147.1 (build d3695d4)

Framework Version

No response

Node.js Version

v22.2.0

OS

mac OS

Language

Python

Language Version

Python

Other information

No response

@syangdh syangdh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 2, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Jul 2, 2024
@khushail khushail added needs-reproduction This issue needs reproduction. and removed needs-triage This issue or PR still needs to be triaged. labels Jul 2, 2024
@khushail khushail self-assigned this Jul 2, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-reproduction This issue needs reproduction. labels Jul 2, 2024
@khushail
Copy link
Contributor

khushail commented Jul 2, 2024

Hi @syangdh , thanks for reaching out. I tried to deploy the VPC in the us-west-2 region and 9 subnets were successfully created. Sharing the code snippet in typescript (deplying in python meanwhile) and Subnets snapshot -

const vpc = new ec2.Vpc(this, 'Ecissue01Vpc', {
      ipAddresses :ec2.IpAddresses.cidr('10.0.0.0/16'),
        maxAzs: 3, 
        natGateways: 1, 
        subnetConfiguration: [
          {
            cidrMask: 24,
            name: 'public',
            subnetType: ec2.SubnetType.PUBLIC,
          },
          {
            cidrMask: 24,
            name: 'private',
            subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
          },
          {
            cidrMask: 24,
            name: 'isolated',
            subnetType: ec2.SubnetType.PRIVATE_ISOLATED
        }]
     });


const app = new cdk.App();
new Ecissue01Stack(app, 'Ecissue01Stack', {
   env: { account: '************', region: 'us-west-2' },
});

Subnets created in us-west-2 -

Screenshot 2024-07-02 at 1 20 49 PM

Could you please check the code and see if something is missing from your side?

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Jul 2, 2024
@khushail
Copy link
Contributor

khushail commented Jul 2, 2024

works well for python as well - 9 subnets created -

Screenshot 2024-07-02 at 1 50 46 PM

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 3, 2024
@khushail khushail added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jul 3, 2024
Copy link

github-actions bot commented Jul 5, 2024

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 5, 2024
@github-actions github-actions bot added closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 10, 2024
@aws-cdk-automation
Copy link
Collaborator

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

3 participants