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(vpc-v2): add add methods to RouteTable and SubnetV2 #31072

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
31d3f48
Add RouteTable addRoute method
Aug 9, 2024
727b164
Update packages/@aws-cdk/aws-ec2-alpha/lib/route.ts
shikha372 Aug 9, 2024
cb8c941
Change CfnRoute to Route L2
Aug 12, 2024
d21be53
Update README.md
Aug 12, 2024
42830e7
Merge branch 'main' into vpcv2-rt-addroute
Leo10Gama Aug 12, 2024
2f48ab2
Update integ test to use only one EIGW
Aug 12, 2024
f904a97
Add subnet associateRouteTable method
Aug 13, 2024
b52d498
Appease the linter
Aug 13, 2024
1aef528
Update subnet with public routeTable again
Aug 13, 2024
9b15a4b
Update subnet-v2.ts
shikha372 Aug 14, 2024
bc56a77
Update subnet-v2.ts
shikha372 Aug 14, 2024
cc8db35
Extend IRouteTable into IRouteTableV2
Aug 14, 2024
285da27
Merge branch 'main' into vpcv2-rt-addroute
shikha372 Aug 14, 2024
98f9d53
ok so route table v2 was not a great idea lol
Aug 14, 2024
b3e08c1
Merge branch 'main' into vpcv2-rt-addroute
Leo10Gama Aug 14, 2024
1211fde
Update testing
Aug 15, 2024
ca9c385
Merge branch 'main' into vpcv2-rt-addroute
shikha372 Aug 15, 2024
eaa7ccb
add method associateRouteTable
shikha372 Aug 14, 2024
a25bb78
fixing route class
shikha372 Aug 15, 2024
1721026
making ipam props private
shikha372 Aug 15, 2024
bc393c2
successful build
shikha372 Aug 15, 2024
aed940f
adding validation for ipv4
shikha372 Aug 15, 2024
499c6c8
fixing egw route and subnet snapshot
shikha372 Aug 16, 2024
f296f3e
fixing readme and route unit test
shikha372 Aug 16, 2024
0002de5
fixing vpc snapshot
shikha372 Aug 16, 2024
909f7da
Update route snapshot
Aug 16, 2024
1b907c1
Update route snapshot
Aug 16, 2024
0dba8bb
Merge branch 'main' into vpcv2-rt-addroute
shikha372 Aug 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-ec2-alpha/lib/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,27 @@ export class RouteTable extends Resource implements IRouteTable, IDependable {

this.routeTableId = this.resource.attrRouteTableId;
}

/**
* Add a new route to the route table.
shikha372 marked this conversation as resolved.
Show resolved Hide resolved
* @param destination The IPv4 or IPv6 CIDR block used for the destination match.
* @param target The gateway or endpoint targeted by the route.
*/
public addRoute(destination: string, target: RouteTargetType) {
if (!target.gateway && !target.endpoint) {
throw new Error('Target is defined without a gateway or endpoint.');
}

let routerType: RouterType = target.gateway ? target.gateway.routerType : RouterType.VPC_ENDPOINT;
let routerTargetId: string = target.gateway ? target.gateway.routerTargetId : target.endpoint!.vpcEndpointId;

new CfnRoute(this, 'Route', {
Leo10Gama marked this conversation as resolved.
Show resolved Hide resolved
routeTableId: this.routeTableId,
destinationCidrBlock: destination,
destinationIpv6CidrBlock: destination,
[routerTypeToPropName(routerType)]: routerTargetId,
});
}
}

function routerTypeToPropName(routerType: RouterType) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,30 @@
}
}
},
"TestRoottableRoute44770015": {
"Type": "AWS::EC2::Route",
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"DestinationIpv6CidrBlock": "0.0.0.0/0",
"EgressOnlyInternetGatewayId": {
"Fn::GetAtt": [
"testEOIGWviaAddRouteEIGWE430E12B",
"Id"
]
},
"RouteTableId": {
"Fn::GetAtt": [
"TestRoottableRouteTableFA28AA38",
"RouteTableId"
]
}
}
},
"eigwSubnetCC28B9F9": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"VpcId": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -80,8 +99,8 @@
"testEIGWRouteEB4FE8D5": {
"Type": "AWS::EC2::Route",
"Properties": {
"DestinationCidrBlock": "0.0.0.0/0",
"DestinationIpv6CidrBlock": "0.0.0.0/0",
"DestinationCidrBlock": "10.0.0.0/24",
"DestinationIpv6CidrBlock": "10.0.0.0/24",
"EgressOnlyInternetGatewayId": {
"Fn::GetAtt": [
"testEOIGWEIGW54CCAD37",
Expand All @@ -95,6 +114,17 @@
]
}
}
},
"testEOIGWviaAddRouteEIGWE430E12B": {
"Type": "AWS::EC2::EgressOnlyInternetGateway",
"Properties": {
"VpcId": {
"Fn::GetAtt": [
"eigwC0F094EF",
"VpcId"
]
}
}
}
},
"Parameters": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Type": "AWS::EC2::Subnet",
"Properties": {
"AssignIpv6AddressOnCreation": false,
"AvailabilityZone": "us-west-1a",
"AvailabilityZone": "us-east-1a",
"CidrBlock": "10.0.0.0/24",
"Ipv6CidrBlock": {
"Fn::Select": [
Expand Down
Loading
Loading