Skip to content

Use ec2.Route instead of inline routes for VPC component #6597

@weston-harper-rox

Description

@weston-harper-rox

There is a known limitation of the AWS provider that prevents inline routes and ec2.Route constructs from working reliably inside a RouteTable definition.

This prevents consumers of the VPC component from adding routes to the VPC's route tables. We'd like to do this to establish a peering connection between accounts for cross-account databases, where the peering connection allows for ingestion of our application database tables into our data warehouse.

Here's a dummy example:

const vpc = new sst.aws.Vpc('VPC', {
  bastion: true,
  nat: 'ec2',
});

vpc.nodes.privateRouteTables.apply((routeTables) => {
  routeTables.map((table, idx) => {
    new aws.ec2.Route(`PeeringRoute${idx}`, {
      routeTableId: table.id,
      vpcPeeringConnectionId: 'pcx-foo',
      destinationCidrBlock: '9.9.9.9/16',
    });
  });
});

While this works some of the time, the limitation leads to state sync errors that bring the peering connection offline and force us to manually rectify.

Request

Use ec2.Route instead of inline routes in createPublicSubnets and createPrivateSubnets in the vpc component.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions