AWS SAM rest api gateway doesn't handle '-' in custom domain properly

108 views Asked by At

I am trying to map a url like 'https://domain.domain/my-api' to rest api gateway, I use the template like:

...
MyAPI:
  Type: AWS::Serverless::Api
  OpenApiVersion: 3.0.0
  Properties:
    Domain:
      BasePath:
        - !Ref URLBasePath
      CertificateArn: !Ref URLCertArn
      DomainName: !Ref URLDomainName
      EndpointConfiguration: EDGE
      Route53:
        HostedZoneId: !Ref HostedZoneID
...

(URLBasePath = 'my-api' URLDomainName = 'domain.domain')

But instead of 'https://domain.domain/my-api' i get 'https://domain.domain/myapi' (the same happens if I use '_' (https://domain.domain/my_api)), but if I map domain manually via console - it works properly.

Am I doing something wrong, or is it a bug (in sam or cloudformation)?

Thank you.

1

There are 1 answers

3
Marcin On

Not sure exactly what are you pasting in your template, but https:// and my-api are not part of a domain. Your DomainName should be only domain.domain.

To specify my-api should use BasePath property.