[@aws-cdk/aws-apigatewayv2] Httpapi not deploying when new stack created when using custom domain
See original GitHub issueHttpapi not deploying when new stack created when using custom domain, and not accepting base path of ‘/’
I tried to follow the description of how to setup a base path mapping here:
https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-readme.html#custom-domain
My actual code was:
const domainName = "test.testdomain.com";
const dn = new apigw.DomainName(this, "DN", {
domainName,
certificate: certificate,
});
const httpApi = new apigw.HttpApi(this, "HttpApi", {
defaultDomainMapping: {
domainName: dn,
mappingKey: "hello",
},
});
When I run this with a stack that has never been deployed before, I get the following error:
Invalid stage identifier specified (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException;
Secondly if I try to change mappingKey to ‘/’ I get the following:
An ApiMapping key may contain only letters, numbers and one of $-_.+!*'(), (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException;
Any help you can give is really appreciated, as this is such a great feature, and when it’s possible to get authentication in there too, that will be icing on the cake!
Error Log
Environment
- CLI Version :
- Framework Version:
- Node.js Version:
- OS :
- Language (Version):
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:16 (7 by maintainers)
Top GitHub Comments
This is the best I could get going:
mappingKey
could neither be""
nor"/"
.path
couldn’t be empty, so the"/"
at the end of the URL is required now.I have the feeling this should work better, but don’t know how.
Hi
At this moment, custom domain only allows to create root base path mapping when there is only one api mapping for this domain. Starting from
v1.54.0
in AWS CDK, simply leave themappingKey
undefined and behind the scene an api mapping with empty api mapping key will be created.However, please note if you create a root path mapping, you can’t create any more api mapping key. This is what we can do with current apigateway v2 custom domain now.