Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apigateway: Cannot rename resource without tearing down whole gateway #25172

Closed
Aeolun opened this issue Apr 18, 2023 · 2 comments
Closed

apigateway: Cannot rename resource without tearing down whole gateway #25172

Aeolun opened this issue Apr 18, 2023 · 2 comments
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@Aeolun
Copy link

Aeolun commented Apr 18, 2023

Describe the bug

I think this is really an issue with CloudFormation, but I'm experiencing it with CDK.

Like described here: serverless/serverless#3785

When I rename a resource with a variable path in my CDK stack, the next deployment will always fail with a A sibling of this resource already has a variable path part. Presumably because CDK/CF are trying to create a new resource before deleting the old one.

I get that this is desired behavior in some cases, but I want the inverse. Delete the existing endpoint first, and then create a new one. I don't think this is something that I should have to manually do by tearing down the whole stack (or at least, whatever part of the API contains the resource) only to re-deploy with the new resource added.

Expected Behavior

I expect to be able to change a resource name from variable to fixed, fixed to variable or variable to catch-all without CDK/CF failing.

Current Behavior

When a resource has it's name changed from variable to fixed, fixed to variable or variable to catch-all, the stack fails to deploy.

Reproduction Steps

const apiGateway = new RestApi(this, "Api", {})
apiGateway.root.resourceForPath('/api')

to

const apiGateway = new RestApi(this, "Api", {})
apiGateway.root.resourceForPath('/{wildcard}')

Possible Solution

I think a way of indicating that you are fine with resources being deleted before being created is fine. This might break your API for a little bit, but since you are already renaming endpoints, this shouldn't be the end of the world.

Additional Information/Context

No response

CDK CLI Version

2.65.0 (build 5862f7a)

Framework Version

No response

Node.js Version

v18.11.0

OS

MacOS Ventura 13.2.1 (22D68)

Language

Typescript

Language Version

4.9.5

Other information

No response

@Aeolun Aeolun added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 18, 2023
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Apr 18, 2023
@pahud pahud self-assigned this Apr 18, 2023
@pahud
Copy link
Contributor

pahud commented Apr 18, 2023

Hi @Aeolun

I was able to update the api deployment from

    const apiGateway = new apigw.RestApi(this, "Api", {})
    apiGateway.root.resourceForPath('/api')
      .addMethod(
        HttpMethod.GET,
      );

to

    const apiGateway = new apigw.RestApi(this, "Api", {})
    apiGateway.root.resourceForPath('/{wildcard}')
      .addMethod(
        HttpMethod.GET,
      );

without any errors. Did I miss anything?

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. bug This issue is a bug. labels Apr 18, 2023
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants