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 Risposta
0
Risposta accettata

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
ESPERTO
con risposta 10 mesi fa
profile pictureAWS
ESPERTO
verificato 9 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande