https://serverless-stack.com/ logo
#help
Title
# help
r

Ross Coundon

04/25/2022, 8:32 PM
I’m trying to upgrade an app from 0.67.0 to 1.0.0-beta.23 and I’m getting deployment failure due to the stage already existing.
Copy code
Stage already exists (Service: AmazonApiGatewayV2; Status Code: 409; Error Code: ConflictException; Request ID: d4d312c4-82e8-44a2-9b16-97c4f9f7b7b7; Proxy: null)
console.js:6
I’ve switched to
Copy code
const api = new sst.Api(this, 'Api', {
      cdk: {
        httpApi: {
          createDefaultStage: false,
        },
        httpStages: [{
          stageName: this.stage,
          autoDeploy: true,
        }]
      },
...
from the previous separate definition
Copy code
const apiStage = new HttpStage(this, 'Stage', {
      httpApi: api.httpApi,
      stageName: this.stage,
      autoDeploy: true,
    });
Have I done something wrong here?
Sorry to bump but wondered if anyone had any thoughts on this?
f

Frank

04/27/2022, 8:06 PM
Trying it out rn..
r

Ross Coundon

04/27/2022, 8:07 PM
brilliant, thank you
f

Frank

04/27/2022, 8:14 PM
Previously,
new HttpStage(this, 'Stage', ...)
the CDK scope for the stage is
this
, which was the Stack.
Now, if you create it inline, the CDK scope for the stage is the
sst.Api
construct, because it’s being created inside the Api.
When scope changes, the HttpStage’s Logical ID inside CloudFormation changes. And when you deploy, CloudFormation would try to remove the old stage, and create a new one.
It’s very anonying that in CDK u can’t change the scope of a construct. You are essentially changing it’s ID, and CFN can’t tell it’s the same resource as before.
Lemme know if that makes sene.
r

Ross Coundon

04/27/2022, 8:18 PM
I see, I think. So what does that mean for the upgrade? I’d need to remove the stage, upgrade, re-add the stage?
f

Frank

04/27/2022, 8:19 PM
Can you keep the code the same way as before? ie.
Copy code
const apiStage = new HttpStage(this, 'Stage', {
      httpApi: api.cdk.httpApi,
      stageName: this.stage,
      autoDeploy: true,
    });
except how u access the http API
api.httpApi
=>
api.cdk.httpApi
r

Ross Coundon

04/27/2022, 8:28 PM
I’ll give that a go, thanks @Frank.