question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(apigateway): RestApi not redeploying correctly

See original GitHub issue

When I change a resource path in a RestApi the old path is not removed from the api stage. The deploy option of RestApi should update the stage when a change occur in the api.

Reproduction Steps

The initial stack:

    const api: RestApi = new RestApi(this, 'rest-api', {
        deploy: true,
        deployOptions: {
            stageName: 'test-stage'
        }
    })

    const myResource:IResource = api.root.addResource("myResource", {})

    myResource.addMethod("GET", 
        new Integration({
            type:IntegrationType.MOCK,
            integrationHttpMethod:'ANY'
        })
    )

The deployed resources: image The stage: image

If I change the path of the resource: const myResource:IResource = api.root.addResource("myResourceChanged", {}) and redeploy the stack

What did you expect to happen?

The expect deployed resources: image The expect stage: image

What actually happened?

The new deployed resources: image The new stage: image

If I manually redeploy the stage from the console, the /myResource is removed from the stage.

Environment

  • **CDK CLI Version :1.103.0 (build bc13a66)
  • Framework Version:
  • **Node.js Version:v14.13.1
  • **OS :Windows 10
  • **Language (Version):TypeScript(3.9.7)

Other


This is 🐛 Bug Report

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:9
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adarsh-chauhancommented, Sep 22, 2022

any update on this?

0reactions
nija-atcommented, May 24, 2021

Actually, the problem is a little more tricky than I originally thought.

In order to cause little or no disruption to running applications during stack updates, CloudFormation ensures that resources are first created and/or updated before any resources are deleted.

CDK automatically creates a default Stage and Deployment whenever a RestApi is created. To ensure that the Deployment is kept in sync with the Rest API definition, the CDK needs to trigger a re-deployment of the Deployment resource. The CDK achieves this by changing the logical id of the Deployment resource which triggers a replacement.

In effect, when a Resource is removed from a RestApi and another added, CloudFormation first creates the new Resource, then creates the new Deployment for the RestApi (that now contains both Resources), then deletes the old Deployment and finally deletes the old Resource. So finally, we end up with a Deployment resource that contains both Resources.

I can’t think of an easy way to solve this problem with just the CDK.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updates to a REST API that require redeployment
Resource updates require redeploying the API, whereas configuration updates do not. API resources that can be updated are detailed in the following table....
Read more >
CloudFormation Does Not Redeploy Your APIG: How To Fix ...
Use the apigateway sdk to delete the stage you want to redeploy. Yes, you read that correctly. Then, create a new deployment and...
Read more >
How do I force redeployment of my API Gateway using ...
This is not working anymore. Changing description of AWS::ApiGateway::Deployment resource just updates the deployment's description field and it ...
Read more >
The problem of updating the apigateway stage in aws cdk.
It doesn't seem to work properly. The addition and modification of resources, methods seem to work well. However, even if RestApi's method is...
Read more >
aws.apigateway.Deployment - Pulumi
To properly capture all REST API configuration in a deployment, this resource ... and will not cause the resource to recreate (redeploy the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found