CDK is deploying resources to stages in API Gateway but not deleting resources from previous deployments though retainDeployments is set to false.

0

I'm trying to deploy a restApi through CDK but while doing this, the resources are created but previous deployments' resources are not getting deleted. More specifically - only the resources from the latest deployments show up in the resources section but all the resources from all previous deployments show up in the stages section. I'm having to deploy the api from the apigateway console manually to delete the resources from previous deployments in the stage(s), which should happen automatically when I deploy the API through CDK. I have set retainDeployments :false, deploy :true, yet the same persists. Is there any way to resolve this such that I don't have to manually deploy from the apigateway console just using CDK?

  • Can you please share the full instantiation of the restApi class with all the props?

  • Also if you initially deployed without deploy: true and retainDeployments: false those resources will likely persist. I recommend manually cleaning out remaining resources and then attempting to deploy with a fresh stack. In my experience those two settings you selected should address the issue you're seeing.

  • I'm instantiating the resources of the restApi recursively. And I've already tried deleting the stack and creating a new one. However the issue still persists. Here is my Api instantiation- const aws_api = new RestApi(this, apiGatewayName, { deployOptions: { accessLogDestination: new LogGroupLogDestination(logGroup), accessLogFormat: AccessLogFormat.jsonWithStandardFields(), stageName: 'prod' }, defaultCorsPreflightOptions: apiGatewayProps.cors, description: apiGatewayProps.description, retainDeployments: false, deploy: true, } );

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions