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): vpc peering connection construct #31645

Merged
merged 46 commits into from
Nov 21, 2024

Conversation

1kaileychen
Copy link
Contributor

@1kaileychen 1kaileychen commented Oct 3, 2024

Issue # (if applicable)

Contributes to closing RFC#507

Tracking: #30762

Reason for this change

This PR implements a new L2 construct to setup VPC Peering Connection.

Description of changes

  • L2 class(VPCPeeringConnection)
  • Function validateVpcCidrOverlap to ensure IPv4 CIDR blocks don't overlap for subnets in the VPCs

Description of how you validated changes

  • Unit tests to test combination of accounts (cross account & cross region, default same account & same region)
  • Unit tests to see simulate when CIDR blocks overlap
    • Primary CIDR block overlaps
    • Secondary CIDR block overlaps
    • Primary and secondary CIDR block overlaps
  • Integration test for peering connection

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team October 3, 2024 22:45
@github-actions github-actions bot added the p2 label Oct 3, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Oct 3, 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 3, 2024 23:18

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

@1kaileychen 1kaileychen marked this pull request as ready for review October 3, 2024 23:20
Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

Awesome stuff!! Just a couple comments.

packages/@aws-cdk/aws-ec2-alpha/lib/route.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-ec2-alpha/lib/route.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-ec2-alpha/lib/route.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-ec2-alpha/lib/route.ts Outdated Show resolved Hide resolved
@moelasmar moelasmar self-assigned this Oct 8, 2024
@shikha372 shikha372 force-pushed the vpc_peering_connection_construct branch from a85eca7 to 7cd8009 Compare November 14, 2024 23:05
@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 15, 2024
@shikha372 shikha372 force-pushed the vpc_peering_connection_construct branch from 102491d to 14d789a Compare November 18, 2024 19:34
@shikha372 shikha372 force-pushed the vpc_peering_connection_construct branch from 14d789a to c0949b5 Compare November 18, 2024 19:38
@shikha372 shikha372 force-pushed the vpc_peering_connection_construct branch from 9aac380 to a6c29e4 Compare November 19, 2024 21:18
@shikha372 shikha372 force-pushed the vpc_peering_connection_construct branch from a6c29e4 to 882a0b5 Compare November 19, 2024 21:20

**Case 2: Same Account and Cross Region Peering Connection**

There is no difference from Case 1 when calling `createPeeringConnection`. The only change is that one of the VPCs are created in another stack with a different region.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also mention that customers need to create a VPC object using the fromVpcAttributes function.

primaryAddressBlock: IpAddresses.ipv4('10.1.0.0/16'),
});

const vpcB = VpcV2.fromVpcV2Attributes(stackA, 'ImportedVpcB', {
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 added V2 name in the function name, I believe this abstract method exists only in the VpcV2 class.

Copy link
Contributor

Choose a reason for hiding this comment

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

this function exists in VpcV2 but there is another function with name fromVpcAttributes that resides in main module currently, imo it is better to name it VpcV2 as both the VPCs have difference in terms of required attributes and fields needed to import, eg. in VPC we don't need to provide AZ details but in VPCv2 it is required.

Comment on lines 268 to 269
const stackA = new Stack(app, 'VpcStackA', { env: { account: '000000000000', region: 'us-east-1' } });
const stackB = new Stack(app, 'VpcStackB', { env: { account: '111111111111', region: 'us-west-2' } });
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be same account

primaryAddressBlock: IpAddresses.ipv4('10.0.0.0/16'),
});

const acceptorRoleArn = acceptorVpc.createAcceptorVpcRole('000000000000') // Requestor account ID
Copy link
Contributor

Choose a reason for hiding this comment

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

missing ;

```

For more information, see [Delete a VPC peering connection](https://docs.aws.amazon.com/vpc/latest/peering/create-vpc-peering-connection.html#delete-vpc-peering-connection).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this section is not required .. or the question is, if the customer removed the peering connection from the CDK application, I am assuming that the peer connection will be deleted is it correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it was added to address this comment #31645 (comment), but I agree we can remove it as peering connection gets deleted if a corresponding CFN stack is deleted.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Nov 21, 2024
@shikha372 shikha372 removed the pr/do-not-merge This PR should not be merged at this time. label Nov 21, 2024
Copy link
Contributor

mergify bot commented Nov 21, 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).

@shikha372
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Nov 21, 2024

update

❌ Mergify doesn't have permission to update

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/codecov.yml without workflows permission

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Copy link
Contributor

mergify bot commented Nov 21, 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 e1195f9 into aws:main Nov 21, 2024
17 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 Nov 21, 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.

5 participants