amplify-education / serverless-domain-manager

Serverless plugin for managing custom domains with API Gateways.
MIT License
936 stars 235 forks source link

Add ability to choose between CNAME and A record #244

Closed vt-cwalker closed 5 years ago

vt-cwalker commented 5 years ago

Community Note

Feature Request

Is your feature request related to a problem? Please describe. When trying to setup a multi-region active-active setup for API Gateway as described here: https://aws.amazon.com/blogs/compute/building-a-multi-region-serverless-application-with-amazon-api-gateway-and-aws-lambda/, I cant do that as the plugin only allows for creating of an A record

Describe the solution you'd like Add the ability to specify whether to add a CNAME record for the regional API endpoint, or to create a A record if the endpointType is regional

custom:
  customDomain:
    domainName: foo.example.tld
    endpointType: regional
    route53RecordType: CNAME | A

Describe alternatives you've considered

There is a way to do something similar manually through traffic policies in Route53, but that costs $50/month, plus has to be done manually

Any Other Info Check for existing A record for the specified domain name, and if not present, create an A record first and then add a CNAME record for the regional endpoint, etc

nbcchen commented 6 months ago

Was this feature being worked on?

LucasSymons commented 6 months ago

Was this feature being worked on?

Dosent look like it was implemented.

https://github.com/amplify-education/serverless-domain-manager/blob/4b17c0561be234fa1e97355b97e6518ebac87d6b/src/aws/route53-wrapper.ts#L134

That shows only A and AAA records are considered.

Can I please second this request, I need to use Cnames so my VPC endpoint picks up the address is for API gateway and routes it correctly allowing resource policies that lock stuff to VPC/VPCendpoints work.

nbcchen commented 6 months ago

@LucasSymons I did find a way to create a CNAME automatically. You can create another Serverless plugin, and add a hook for after the deployment. In the plugin, make a ChangeResourceRecordSets request using the Serverless library or AWS SDK for Route53 (included in this plugin already). I recommend the AWS SDK because it is more intuitive.