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개 답변
0
수락된 답변

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
전문가
답변함 10달 전
profile pictureAWS
전문가
검토됨 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠