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 Resposta
0
Resposta aceita

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
ESPECIALISTA
respondido há 10 meses
profile pictureAWS
ESPECIALISTA
avaliado há 9 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas