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

Any plans to support explicit cidrs ranges within VPC? #7333

Closed
2 tasks done
moatazelmasry2 opened this issue Apr 13, 2020 · 1 comment
Closed
2 tasks done

Any plans to support explicit cidrs ranges within VPC? #7333

moatazelmasry2 opened this issue Apr 13, 2020 · 1 comment
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@moatazelmasry2
Copy link
Contributor

moatazelmasry2 commented Apr 13, 2020

So I had a requirement from a customer to create a VPC with specific CIDRs for the subnets. While I'm able to provide subnet configuration within a vpc and provide a netmask for public/private subnets, I'm not able to specify the exact cidr range within the subnet configuration.

I solved my problem by just creating every element in the vpc by hand, which is not ideal tbh. Here's my actual solution:

export class NetworkSetupStack2 extends cdk.Stack {
    constructor(scope: cdk.Construct, id: string, props: AccountSetupProps) {
        super(scope, id, props);
        const context = props.context
        const vpc = new ec2.Vpc(this, 'VPC2', {
            cidr: "10.249.0.0/21",
            maxAzs: 3,
            subnetConfiguration: []
        });
        const publicSubnet2a = new ec2.PublicSubnet(this, "PublicSubnet2a", {
            cidrBlock: "10.249.6.0/28",
            vpcId: vpc.vpcId,
            availabilityZone: "eu-central-1a"
        })
        const privateSubnet2a = new ec2.PrivateSubnet(this, "PrivateSubnet2a", {
            cidrBlock: "10.249.0.0/23",
            vpcId: vpc.vpcId,
            availabilityZone: "eu-central-1a"
        })
        const internetGateway = new ec2.CfnInternetGateway(this, 'InternetGateway', {
        })
        const att = new ec2.CfnVPCGatewayAttachment(this, 'VPCGatewayAttachement', {
            internetGatewayId: internetGateway.ref,
            vpcId: vpc.vpcId
        })
        publicSubnet2a.addDefaultInternetRoute(internetGateway.ref, att)
        const natProvider = ec2.NatProvider.gateway()
        natProvider.configureNat({
            vpc: vpc,
            natSubnets: [publicSubnet2a],
            privateSubnets: [privateSubnet2a]
        })
  }
}

Use Case

In an enterprise environment, you get certain IP ranges allocated by the enterprise and you sometimes need to map those ranges in a very specific way. An automatic distribution by aws cdk is not precise enough.

Proposed Solution

const vpc = new ec2.Vpc(this, 'VPC2', {
            cidr: "10.249.0.0/21",
            maxAzs: 3,
            subnetConfiguration: [
                {
                    cidrMask: 23,
                    subnetType: SubnetType.PRIVATE,
                    Subnets: [
                        {
                            name: "PrivateSiubnet1a"
                            cidrRange: "10.249.0.0/23",
                            availabilityZone: "eu-central-1a"
                        },
                        {
                            name: "PrivateSiubnet1b"
                            cidrRange: "10.249.2.0/23",
                            availabilityZone: "eu-central-1b"
                        },
                        {
                            name: "PrivateSiubnet1a"
                            cidrRange: "10.249.04.0/23",
                            availabilityZone: "eu-central-1c"
                        }
                    ]
                }
            ],
            natGateways: 3
        });

Other

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@moatazelmasry2 moatazelmasry2 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 13, 2020
@moatazelmasry2 moatazelmasry2 changed the title Any plans to support explicit cidrsranges within VPC? Any plans to support explicit cidrs ranges within VPC? Apr 13, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Apr 16, 2020

Duplicate: #7073
Related: #5927

@rix0rrr rix0rrr closed this as completed Apr 16, 2020
@SomayaB SomayaB added @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud and removed package/vpc labels May 27, 2020
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 feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants