Unable to map Rest API with custom domain using AWS CDK.

0

Hi, I have an API that I want to map with my custom domain. But I am getting this error - "Invalid stage identifier specified (Service: ApiGateway, Status Code: 400, Request ID: 461a0c54-ddd6-4df5-adce-d6b813208446)".

The following code I am using for API mapping -

const myAPI = new RestApi(this, MyRestAPI, { deployOptions: { stageName: props.stage, }, }); new CfnBasePathMapping(this, myAPIMapping, { basePath: 'myapi', domainName: props.domainName.domainName, restApiId: myAPI.restApiId, stage: props.stage, });

Please help me with your valuable suggestion. Thanks you.

1 Antwort
0
Akzeptierte Antwort

Is the API Gateway stage created at the same time as this stack?
If the mapping is created before the API Gateway stage, the error message "Invalid stage identifier specified" may appear.
If they are created at the same time, try using "addDependency" and wait for the API Gateway stage to be created.
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib-readme.html#dependencies

The following code may fix the problem.

const CfnBasePathMapping = new CfnBasePathMapping(this, myAPIMapping, { basePath: 'myapi', domainName: props.domainName.domainName, restApiId: myAPI.restApiId, stage: props.stage, });
CfnBasePathMapping.addDependency(myAPI);
profile picture
EXPERTE
beantwortet vor 10 Monaten
profile pictureAWS
EXPERTE
überprüft vor 9 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen