serverless-domain-manager icon indicating copy to clipboard operation
serverless-domain-manager copied to clipboard

Can I use DomainName and DistributionDomainName values in serverless.yml?

Open FergusMcGlynn opened this issue 4 years ago • 1 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Support Question

Question

serverless-domain-manager provides Cloudformation outputs DomainName and DistributionDomainName - is there any way to make use of these values within serverless.yml?

I am not using Route 53 for domain management, and I'm setting createRoute53Record to false, so I need to create my own DNS CNAME entry that points my domain name to the behind-the-scenes CloudFront distribution. This is fine - my organisation has a custom Cloudformation task for doing this. The only issue is that I need the value of CloudFront distribution domain name to use as an input to this custom task, and I can't work out how to get it. The Serverless application returns this value as a Cloudformation output called DistributionDomainName, so I'd have thought it should be possible to reference it in serverless.yml somehow. Is there a way?

I was hoping to be able to append some Cloudformation to serverless.yml like this:

resources:
  Resources:
    MyCNAME:
      Type: Custom::CNAME   # custom Cloudformation resource for creating ad-hoc CNAME entries
      Properties:
        Source: "my.domain.com."
        Target: ??? CloudFront URL here ???

but as I say I can't work out how, or if it's possible, to reference the CloudFront URL in this way. I suppose I could create a separate Cloudformation stack and reference the DistributionDomainName output from the Serverless application stack in this new stack, but I'd prefer to do everything in one stack if possible.

Command Run sls deploy

Domain Manager Configuration

custom:
  customDomain:
    domainName: my.example.com
    basePath: ''
    stage: dev
    createRoute53Record: false
    autoDomain: true

Versions

  • Domain Manager version(s): 4.2.0
  • Node/npm version: Node 12, NPM 6.9.0
  • Serverless Version: 1.78.1
  • Lambda Code: Javascript

FergusMcGlynn avatar Aug 21 '20 13:08 FergusMcGlynn