Ross Gerbasi
01/15/2022, 4:16 PMApiA
(xxxyyy.execute-api.region.amazonaws.com) and ApiB
(aaabbb.execute-api.region.amazonaws.com) and you want to end up with <http://api.example.com/v1/apia|api.example.com/v1/apia>
and <http://api.example.com/v1/api|api.example.com/v1/api>
. This could be a much less costly solution then an edge lambda or worker to change requests. I'll throw the code in the thread to not fill up the room here.Ross Gerbasi
01/15/2022, 4:16 PMimport { DomainName } from '@aws-cdk/aws-apigatewayv2-alpha'
import { Certificate, CertificateValidation } from 'aws-cdk-lib/aws-certificatemanager'
const domain = new DomainName(this, 'APIDomain', {
domainName: `<http://xxx.example.com|xxx.example.com>`,
certificate: new Certificate(this, 'MyCert', {
domainName: '<http://xxx.example.com|xxx.example.com>',
validation: CertificateValidation.fromDns(),
}),
})
const myAPI = new Api(this, 'myAPI', {
defaultFunctionProps: {
srcPath: 'src/api',
},
routes: {
'GET /example': 'example.get'
},
})
new ApiMapping(this, 'AuthAPIMapping', {
api: myAPI.httpApi,
domainName: domain,
apiMappingKey: `custom/path`,
})
Ross Gerbasi
01/15/2022, 4:19 PMcustomDomain
could add this? maybe a isExternalDomain
like static sites, to skip Route53, and options to switch to mapping? Would be nice as it handles certs well already.Frank
const myAPI = new Api(this, 'myAPI', {
customDomain: {
domainName: "<http://xxx.example.com|xxx.example.com>",
isExternalDomain: true,
certificate: new Certificate(this, 'MyCert', {
domainName: '<http://xxx.example.com|xxx.example.com>',
validation: CertificateValidation.fromDns(),
}),
path: "custom/path",
},
...
})
Frank
Ross Gerbasi
01/15/2022, 8:45 PMRoss Gerbasi
01/15/2022, 8:46 PMdomainName: refToDomainName,
path: "custom/path"
Ross Gerbasi
01/15/2022, 8:47 PMFrank
domainName: refToDomainName,
path: “custom/path”That should work already
Frank
Ross Gerbasi
01/15/2022, 8:48 PMRoss Gerbasi
01/15/2022, 8:49 PMisExternalDomain
then? to opt out of the hostzone stuff?Ross Gerbasi
01/15/2022, 8:51 PMFrank
refToDomainName
, SST will not try to create anything in Route 53, it should work i think.Ross Gerbasi
01/15/2022, 8:54 PMRoss Gerbasi
01/15/2022, 8:58 PMisExternalDomain
and allowing domainName
to be a string. Then having the construct build up the APiGateway domain with the path, instead of passing in a DomainName
Not a big deal for me as I need to share my DomainName
anyway. but maybe for someone that just has a single api they wanna throw up on a domain but don't want route53. They can obviously create the domain themselves, but if the construct could hide some complexity of certs maybe that would be helpful?Ross Gerbasi
01/15/2022, 9:07 PMFrank