When setting up custom domains with the API constr...
# sst
s
When setting up custom domains with the API construct, is there a preferred method to handle subdomains that already exist?
My API Stack fails to deploy when the domain already exists (previous created outside of SST).
Copy code
| CREATE_FAILED | AWS::ApiGatewayV2::DomainName | apiDomainName37D05E46 The domain name you provided already exists. (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: ef930e10-ffea-4d93-9f28-8acd6b84d2d9; Proxy: null)
Also, kudos to how easy it is to define a custom domain. It took me a lot longer to get all that sorted out in Serverless
f
@Seth Geoghegan So the domain has already been added in Api Gateway, and you just want to map the api as a new path?
s
Yes, that's the scenario. I suppose I could just delete the existing custom domain in API Gateway and let SST re-create it. It just took me so long to get right in Serverless, that I'm a little gun shy 😆
f
Oh yeah I can probably push out a release with it later today
s
Just to make sure I'm being clear about the use case.... I'm porting over a Serverless Framwork app to SST. Most of the resources can be re-created with no problem (e.g. DynamoDB tables, S3 buckets, API Gateway routes,etc). It's not really a problem if SST replicates these resources
However, I don't really want my API routes and Route 53 domain names to change. I still want to use api.<mydomain>.com and dev-api.<mydomain>.com.
f
so, you already have Route53 setup, an ACM certificate, and the custom domain added in API Gateway
s
I guess I could just blow away the existing API Gateway Custom domain and let SST re-create it. I'm just not clear on how this would effect my Route 53 setup
Yes, exactly
f
Yup yup, either way works.
s
I'm inclined to just let SST do it all, since I'd ultimately like all of this to be managed by SST. I guess I'm just not sure of the best practice here, or if this is a common problem. Chances are, if it's not common, i'm probably overthinking it 🙂
f
Yeah.. the only think i can think of is if down the road, if you were to create ie. staging-api.domain.com do you want to set that up manually or do that through SST.
s
right, i'd hate to have a one-off
I'll try deleting my development custom domain and trying it again in SST, no harm in that. I much prefer the interface you have in the Api construct
OK, I removed the custom domain in API Gateway, but the stack update failed because the Rout53 A record set already existed
Copy code
UPDATE_FAILED | AWS::Route53::RecordSet | apiAliasRecordEE762719 [Tried to create resource record set [name='dev-api.signupandrace.com.', type='A'] but it already exists]
deleting the A record and trying again.
f
Ah yup. Let me know how it goes.
s
it all worked out
I had some funky stack states in my dev environment, so i ended up dropping the entire stack and re-deploying
which worked out
f
Awesome!