I’m trying to upgrade an app from 0.67.0 to 1.0.0-...
# help
r
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
Trying it out rn..
r
brilliant, thank you
f
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
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
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
I’ll give that a go, thanks @Frank.