aws-cdk: (aws-apigateway): RestApi imported with method fromRestApiAttributes not updating current deployment in stage
I’ve imported from a serverless project this restApi.
const restApiId = cdk.Fn.importValue(envRelated(`ApiGateway-restApiId`));
const rootResourceId = cdk.Fn.importValue(envRelated(`ApiGateway-rootResourceId`));
this.apiGw = apigateway.RestApi.fromRestApiAttributes(this, envRelated(`apigw`), {
restApiId: restApiId,
rootResourceId: rootResourceId,
});
When deploying with cdk deploy, all resources are updated but not the stage. No deployment is created. I’ve tried also to force a deployment with this snippet.
new Deployment(this,envRelated('deployment-stage') , {
api: apiGw
});
Salting the deployment id makes no difference. After the deployment is done, the api gateway is still pointing to the previous deployment instead of the new deployment done.

Specifying the stage with the forced deployment fails because stage already exists.
Environment
- CDK CLI Version: 1.9.2
- Module Version: 1.9.2
- Node.js Version: 12.14.1
- OS: Ubuntu Linux 20.04
- **Language: ts
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 21 (7 by maintainers)
Seriously guys, I’m tired of this. CDK Development is 95% google search, and 5% actual coding. The documentation is horrendous, you really need to make it a priority to update it. The above almost worked for me. The issue, if you look at the template, is that the deployment is created in parallel with everything else if there is no dependency on anything, and winds up running first before the actual new resource or whatever is applied to an existing gateway. I couldn’t depend on the “FromResourceAttribute” object cuz it didn’t add a dependency to the template for some reason. I had to have the Deployment depend on the new resource I added. For those who find this, here is example .Net code that worked for me. You can convert this to the language of your choice: (Btw, this is CDK V2 code from version 2.88.0)
` var stack = new Stack(scope, id, stackProps);