Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions API.md

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

Empty file added CHANGELOG.md
Empty file.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,7 @@ Here’s a breakdown of the configuration options available:
4. externalSubnets: Specify external subnets if you need to define subnets manually (each with an id, availabilityZone, and routeTableId).
5. iamPolicyStatements: (Optional) Attach IAM policy statements to control access to the endpoint.
6. additionalTags: (Optional) Add custom tags to the VPC Endpoint for easier identification and tracking.



- :white_check_mark: Configurable route table entry naming for subnet routes via `routeTableStringFormat`
26 changes: 16 additions & 10 deletions src/constructs/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface ISubnetsProps {
readonly ingressNetworkACL?: NetworkACL[];
readonly egressNetworkACL?: NetworkACL[];
readonly routes?: AddRouteOptions[];
readonly routeTableStringFormat?: boolean;
readonly tags?: Record<string, string>;
readonly useSubnetForNAT?: boolean;
readonly useNestedStacks?: boolean;
Expand Down Expand Up @@ -267,11 +268,18 @@ export class Network extends Construct {
},
);
option.routes?.forEach((route, routeIndex) => {
const useNewFormat = option.routeTableStringFormat ?? false;
const destinationKey =
route.routeName ?? route.destinationCidrBlock?.replace(/[./]/g, '-');

const routeTableName =
useNewFormat && destinationKey
? `${option.subnetGroupName}-${destinationKey}-Route`
: `${option.subnetGroupName}${routeIndex}RouteEntry`;
if (peeringConnectionId != undefined && route.existingVpcPeeringRouteKey != undefined) {
let routeId: ec2.CfnVPCPeeringConnection | undefined = peeringConnectionId[route.existingVpcPeeringRouteKey];
if (routeId != undefined) {
subnet.addRoute(
`${option.subnetGroupName}${routeIndex}RouteEntry`,
subnet.addRoute(routeTableName,
{
routerId: routeId.ref,
routerType: route.routerType,
Expand All @@ -280,14 +288,12 @@ export class Network extends Construct {
);
}
} else if (route.routerId != undefined) {
subnet.addRoute(
`${option.subnetGroupName}${routeIndex}RouteEntry`,
{
routerId: route.routerId ?? '',
routerType: route.routerType,
destinationCidrBlock: route.destinationCidrBlock,
},
);
// Check the value of option.routeTableStringFormat to format the route name accordingly
subnet.addRoute(routeTableName, {
routerId: route.routerId ?? '',
routerType: route.routerType,
destinationCidrBlock: route.destinationCidrBlock,
});
}

});
Expand Down
Loading