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

feat(vpcV2): support custom route and subnet #30538

Merged
merged 164 commits into from
Aug 7, 2024
Merged

Conversation

shikha372
Copy link
Contributor

@shikha372 shikha372 commented Jun 12, 2024

Issue # (if applicable)

Closes RFC#507.

Issue#5927

Tracking Ticket #30762

Reason for this change

This PR implements below RFC for Full Control VPC configuration
Implementing RFC Full Control VPC

Description of changes

A new Experimental API for VPC called VPCv2
Lifecycle Doc: https://github.com/cdklabs/team-internal/blob/main/docs/construct-library-lifecycle.md

  • Introduced a new alpha module for VPCV2
  • Both new class VPCV2 and SubnetV2 implement IVPC and ISubnet for compatibility with other constructs
  • Introduced a new IPAM class to support IP address alllocation through IPAM pool.
  • Validations of IP ranges assigned to subnet.
  • L2 class(Route) to define custom routes under the subnet
  • L2s for gateways like Egress only IGW and NATGW.

Next Steps:

Iterate on the API with the feedback from community and team to make it ergonomic.
Close on the features listed in tracking ticket

Will follow the exit criteria for this experimental API as outlined in below doc:
https://github.com/cdklabs/team-internal/blob/main/docs/construct-library-lifecycle.md

Description of how you validated changes

Added unit tests with current coverage ~70%

Added integration tests for subnet, vpc and routing features.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Jun 12, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team June 12, 2024 23:50
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jun 12, 2024
aws-cdk-automation

This comment was marked as resolved.

@shikha372 shikha372 changed the title Vpc full control (vpc:) support custom route and subnet Jun 13, 2024
@shikha372 shikha372 changed the title (vpc:) support custom route and subnet feat(vpc): support custom route and subnet Jun 13, 2024
/**
* The operating Regions for an IPAM.
* Operating Regions are AWS Regions where the IPAM is allowed to manage IP address CIDRs
* For more information about operating Regions, see [Create an IPAM](https://docs.aws.amazon.com//vpc/latest/ipam/create-ipam.html) in the *Amazon VPC IPAM User Guide* .
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to check how this will look like in Docs

packages/@aws-cdk/aws-vpcv2-alpha/lib/ipam.ts Outdated Show resolved Hide resolved
Comment on lines 341 to 348
public provisionCidr(id: string, options: IpamPoolCidrProvisioningOptions): CfnIPAMPoolCidr {
const cidr = new CfnIPAMPoolCidr(this, id, {
...options,
ipamPoolId: this.ipamPoolId,
});
this.ipamCidrs.push(cidr);
return cidr;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[non blocking] should we add validation to the input CIDR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be used for both ipv4 and ipv6 but mainly used to provision CIDRs with netmasklength as mentioned in the documentation
Can be used for provisioning Amazon-provided IPv6 CIDRs to top-level pools and for provisioning CIDRs to pools with source pools. Cannot be used to provision BYOIP CIDRs to top-level pools. "NetmaskLength" or "Cidr" is required.

So I believe the validation should be around netmask length, added a point to think about all the validations in IPAM class.

packages/@aws-cdk/aws-vpcv2-alpha/lib/ipam.ts Outdated Show resolved Hide resolved
*/
public readonly operatingRegions: string[];

constructor(scope: Construct, id: string, props?: IpamProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

i believe the node.defaultChild of this construct is the CfnIpam resource.

*/
public readonly operatingRegions: string[];

constructor(scope: Construct, id: string, props?: IpamProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[to think about] shall we add a validation that number of Ipam created per stack is only one ?

packages/@aws-cdk/aws-vpcv2-alpha/lib/subnet-v2.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-vpcv2-alpha/lib/subnet-v2.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-vpcv2-alpha/lib/subnet-v2.ts Outdated Show resolved Hide resolved
* gateway and cannot be specified with a private NAT gateway.
* @default none
*/
readonly allocationId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

so I think we should add a constructor for it.

Comment on lines 511 to 522
if (this.targetRouterType == RouterType.GATEWAY) {
if (this.target.gateway instanceof InternetGateway) {
new CfnVPCGatewayAttachment(this, 'GWAttachment', {
vpcId: this.target.gateway.vpcId,
internetGatewayId: this.target.gateway.routerTargetId,
});
} else if (this.target.gateway instanceof VPNGateway) {
new CfnVPCGatewayAttachment(this, 'GWAttachment', {
vpcId: this.target.gateway.vpcId,
vpnGatewayId: this.target.gateway.routerTargetId,
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this will be done in next phases, but I want to keep track of the comments that will be done later to facilitate my review next time :)

The attachment should be moved to the place where we create the Gateways.

Copy link
Contributor Author

@shikha372 shikha372 Aug 2, 2024

Choose a reason for hiding this comment

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

Thanks @moelasmar , that's why i'm keeping this comment as unresolved so we could revisit this in next implementation along with adding in feature plan

*/
class IpamIpv4 implements IIpAddresses {

constructor(private readonly props: IpamOptions, private readonly ipProps?: SecondaryAddressProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you make a new object for the name property ?

@shikha372 shikha372 added the pr/do-not-merge This PR should not be merged at this time. label Aug 7, 2024
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b717d17
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@shikha372 shikha372 removed the pr/do-not-merge This PR should not be merged at this time. label Aug 7, 2024
Copy link
Contributor

mergify bot commented Aug 7, 2024

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit e17fdd7 into aws:main Aug 7, 2024
12 checks passed
Copy link

github-actions bot commented Aug 7, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2024
@shikha372 shikha372 changed the title feat(vpc): support custom route and subnet feat(vpcV2): support custom route and subnet Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p2 pr/needs-maintainer-review This PR needs a review from a Core Team Member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants