Skip to content

AWS::EC2::Route fails to create because of a dependencies does not exist

0

I'm trying to get create a S3 VPC Gateway endpoint and add that to the route table as it works in my console. I have this working defined in my console, but I need to replicate it in Cloudformation template so I can more easily re-use it. So I have my Cloudformation for S3 VPC Endpoint definition and the Route for it like so:

  VpceS3:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      VpcId: !Ref FuseAppVpc
      VpcEndpointType: Gateway
      ServiceName: !Sub com.amazonaws.${AWS::Region}.s3
      PrivateDnsEnabled: false
  VpcePrefixList:
    Type: AWS::EC2::PrefixList
    Properties:
      PrefixListName: !Sub com.fuseanalytics.${AWS::Region}.s3
      AddressFamily: IPv4
      MaxEntries: 10
      Entries:
        - Cidr: 16.15.176.0/20
        - Cidr: 16.15.192.0/18
        - Cidr: 16.182.0.0/16
        - Cidr: 18.34.0.0/19
        - Cidr: 18.34.232.0/21
        - Cidr: 3.5.0.0/19
        - Cidr: 52.216.0.0/15
        - Cidr: 54.231.0.0/16
  PrivateVpceS3GatewayRoute:
    Type: AWS::EC2::Route
    DependsOn: VpceS3
    Properties:
      RouteTableId: !Ref AppVpcPrivateRouteTable
      DestinationPrefixListId: !Ref VpcePrefixList
      GatewayId: !Ref VpceS3

However, when I deploy it I get the following message:

Resource handler returned message: "The gateway ID 'vpce-01374dae7bf29b771' does not exist (Service: Ec2, Status Code: 400, Request ID: f023d58b-c94c-4f6e-9745-f723056ba605)"

And I see it create the VpceS3 prior to creating the route. I also added the DependsOn property to the route, and it still says it doesn't exist.

2024-08-20 12:52:36 UTC-0400  PrivateVpceS3GatewayRoute  CREATE_FAILED
....
2024-08-20 12:52:26 UTC-0400  VpceS3  CREATE_COMPLETE
2024-08-20 12:52:26 UTC-0400  VpceS3  CREATE_IN_PROGRESS

So why is this not working?

1 Answer
1
Accepted Answer

Hi, I recommend visiting this documentation to understand how routing configured when you are using S3 endpoint type Gateway: https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-s3.html#associate-route-tables-s3

The steps taken are a bit different than adding a route to your table. Simply just associate the Gateway with the route table and AWS will take care of adding the routes and influence traffic from VPCs using this route table. So the method using GatewayId isn't for S3 Gateway endpoints.

during the steps of creating the VPC endpoint type Gateway, associate the route table to the Gateway using the property RouteTableIds shown here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpcendpoint.html#cfn-ec2-vpcendpoint-routetableids

If that helped solving the problem, please accept the answer.

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.