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

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

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
Comment on lines +496 to +511
peeringRole.addToPolicy(new PolicyStatement({
effect: Effect.ALLOW,
actions: ['ec2:AcceptVpcPeeringConnection'],
resources: [`arn:${Aws.PARTITION}:ec2:${this.region}:${this.ownerAccountId}:vpc/${this.vpcId}`],
}));

peeringRole.addToPolicy(new PolicyStatement({
actions: ['ec2:AcceptVpcPeeringConnection'],
effect: Effect.ALLOW,
resources: [`arn:${Aws.PARTITION}:ec2:${this.region}:${this.ownerAccountId}:vpc-peering-connection/*`],
conditions: {
StringEquals: {
'ec2:AccepterVpc': `arn:${Aws.PARTITION}:ec2:${this.region}:${this.ownerAccountId}:vpc/${this.vpcId}`,
},
},
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not see grant methods exist in the VPC interface, I may be wrong. I believe we need to have some grant methods, and refactor this function later to use the grant methods. I will leave this to @shikha372 to decide what is correct here.

Copy link
Contributor

Choose a reason for hiding this comment

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

there is no method currently in VPC, but I agree we can model these permissions under grant method with something like grantPeeringConnection(grantee: iam.IGrantable) and account id as principal, i'll add it in.

@shikha372 shikha372 added the pr/do-not-merge This PR should not be merged at this time. label Oct 16, 2024
Co-authored-by: Shikha Aggarwal <[email protected]>
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@moelasmar moelasmar removed their assignment Oct 18, 2024
@shikha372 shikha372 self-assigned this Oct 18, 2024
@paulhcsun paulhcsun self-requested a review October 21, 2024 17:34
@paulhcsun paulhcsun dismissed their stale review October 21, 2024 17:36

Changes have been addressed.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS. p2 pr/do-not-merge This PR should not be merged at this time. 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