Skip to content

Possible to Use SAM with multiple API Gateways in different template.yml with custom domains? #2703

Discussion options

You must be logged in to vote

I was able to achieve this; the key is the AWS::ApiGateway::BasePathMapping definition. You can either define your custom dns name (let's say api.hostname.com) manually using the Console or CloudFormation or it's better to define the DNS in your "root" SAM Lambda project because you can automatically associate your Route 53 DNS A record to API Gateway.

But let's assume you already have api.hostname.com added as a custom domain in API Gateway. Set up two SAM projects, one for each of your microservices. Define an API Gateway in each:

Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: Prod

If you want your microservice to also create the DNS record a…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@hoffa
Comment options

@EchoWhiskeyZero
Comment options

Comment options

You must be logged in to vote
4 replies
@EchoWhiskeyZero
Comment options

@stevenulibarri
Comment options

@mcblair
Comment options

@stevenulibarri
Comment options

Answer selected by EchoWhiskeyZero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants