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(ec2-alpha): adding imports for SubnetV2 and VpcV2(WIP) #31765

Merged
merged 11 commits into from
Oct 29, 2024

Conversation

shikha372
Copy link
Contributor

@shikha372 shikha372 commented Oct 15, 2024

Issue # (if applicable)

Tracking #30762.

Reason for this change

Allow users to define imports for a VPC or subnet defined outside current stack definition.

Description of changes

  • Added new methods under VpcV2 and Subnet
    VpcV2.fromVpcV2Attributes() and SubnetV2.fromSubnetV2Attributes()

  • Added new L2 for VPCCidrBlock to allow import of secondary addresses.
    VPCCidrBlock

  • Added new integration test and unit test file to check import related functionality.

  • Updated Readme.

  • Fixed an earlier issue with subnet range check, fixed to include IPAM defined IPv4 address as well

Description of how you validated changes

Deployed and tested for below scenarios in account:

  1. Import a VPC with primary IPv4
  2. Import a subnet with primary IPv4
  3. Import a VPC with multiple secondary IPv4
  4. Import a VPC with Amazon provided IPV6
  5. Import a VPC with Ipam provided IPv6/IPv4
  6. Import subnet individually using fromSubnetV2attributes
  7. Imported different type of multiple subnets
  8. Add gateways/endpoint to imported vpc

Checklist

BREAKING CHANGE: The new VpcCidrBlock L2 construct replaces CfnVPCCidrBlock. This change alters the logical ID of AWS::EC2::VPCCidrBlock resources in CloudFormation templates. Existing deployments will see errors like CIDR range conflicts with x.xx.xx.xx/xx with association ID vpc-cidr-assoc-ABCD. To resolve this, you must recreate your existing stacks to use the new module.


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 Oct 15, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team October 15, 2024 18:55
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 15, 2024
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review October 16, 2024 17:52

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@shikha372 shikha372 changed the title feat(VpcV2): adding imports for Subnetv2 and VPCv2(WIP) feat(VpcV2): adding imports for SubnetV2 and VpcV2(WIP) Oct 16, 2024
@shikha372 shikha372 marked this pull request as ready for review October 16, 2024 21:26
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 16, 2024
subnetType: SubnetType.PRIVATE_ISOLATED,
availabilityZone: 'us-west-2a',
ipv4CidrBlock: '10.2.0.0/24',
routeTableId: 'rtb-0871c310f98da2cbb',
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the value of providing the route table id? if it is needed, is it better to provide the route table object ?

Copy link
Contributor Author

@shikha372 shikha372 Oct 24, 2024

Choose a reason for hiding this comment

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

it will be used to add routes when attaching gateways, since routeTable interface only has the routeTableId as the property, i think just providing the Id should be enough to modify the class field using routetable id

this.routeTable = {
     routeTableId: props.routeTableId!,
   };

Copy link
Contributor

Choose a reason for hiding this comment

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

honestly, I do not have a strong opinion about it. The only thing I have in mind is passing an object will give us and customers other options to create the route table, and do more logic by invoking other functions.

In general in CDK, we prefer using strong typed Objects more than Ids.

@@ -9,7 +9,7 @@
"InstanceTenancy": "default"
}
},
"VPCintegtest1SecondaryAddress256BAC1D3": {
"VPCintegtest1SecondaryAddress2B60D56E9": {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you know why these logical ids got changed although you did not change anything in the testing stack

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 be careful about the logical ids changes, as it means that the old resources will be deleted, and create new resources, and this can be a breaking change for the customers.

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 it is related to the change in packages/@aws-cdk/aws-ec2-alpha/lib/vpc-v2.ts when you replaced the CfnVPCCidrBlock resource with the new L2 resource. Could you please check if this is a breaking change (I mean if it will cause any outage for the customers or not during the update). If yes, I think it is ok since this module is an alpha module, but we need to highlight the change as a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I verified that this is a breaking change. The stacks that got already deployed using the old construct will fail to be updated after this change and will get this error CIDR range conflicts with x.xx.xx.xx/xx with association ID vpc-cidr-assoc-ABCD .. we should highlight this issue as a breaking change.

@moelasmar moelasmar added the pr/do-not-merge This PR should not be merged at this time. label Oct 25, 2024
Copy link
Contributor

@moelasmar moelasmar left a comment

Choose a reason for hiding this comment

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

Thanks Shikha, it looks good to me.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 25, 2024
@moelasmar moelasmar changed the title feat(VpcV2): adding imports for SubnetV2 and VpcV2(WIP) feat(ec2-alpha): adding imports for SubnetV2 and VpcV2(WIP) Oct 26, 2024
@moelasmar moelasmar removed the pr/do-not-merge This PR should not be merged at this time. label Oct 28, 2024
@moelasmar moelasmar added pr/do-not-merge This PR should not be merged at this time. and removed pr/do-not-merge This PR should not be merged at this time. labels Oct 28, 2024
@moelasmar
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Oct 28, 2024

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@moelasmar
Copy link
Contributor

@Mergifyio merge

Copy link
Contributor

mergify bot commented Oct 29, 2024

merge

❌ Sorry but I didn't understand the command. Please consult the commands documentation 📚.

@moelasmar
Copy link
Contributor

@Mergifyio queue

Copy link
Contributor

mergify bot commented Oct 29, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at d108a80

@mergify mergify bot merged commit d108a80 into aws:main Oct 29, 2024
11 checks passed
Copy link

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 Oct 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants