Description
A DynamoDB gateway endpoint adds a service route only to its associated route tables.
Potential impact
Without that route, an application subnet may lose access or reach DynamoDB through NAT or an internet gateway.
Remediation
Find the route table the application subnet actually uses and add it to the endpoint’s route_table_ids. Verify that all three resources share a VPC and that access policies allow the application’s operations.
Examples
The second excerpt associates private_rtb2 with both private_subnet2 and the DynamoDB endpoint.
Before
hcl
resource "aws_vpc_endpoint" "dynamodb_vpce" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.us-east-1.dynamodb"
}
After
hcl
resource "aws_route_table_association" "private_rtb_assoc" {
subnet_id = aws_subnet.private_subnet2.id
route_table_id = aws_route_table.private_rtb2.id
}
resource "aws_vpc_endpoint" "dynamodb_vpce" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.us-east-1.dynamodb"
route_table_ids = [aws_route_table.private_rtb2.id]
}