-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(aws-apigateway): RestApi imported with method fromRestApiAttributes not updating current deployment in stage #13526
Comments
@evilsephiroth try this you need to bust the deployment sha with
and for a specific stage
|
Added the logicalId but no change. Still the deployment occurs but it's not selecting the latest deployment in the stage. |
Hey @evilsephiroth, I am unsure as to why this was not correctly marked as a bug report, but I have now corrected it. Someone from the team will attempt to reproduce your issue as soon as able. Please let us know if you have any updates, and we will update this issue when there is an opportunity to investigate further. |
@evilsephiroth I have the same issue. Unable to run new deployment to update a stage in API Gateway. Tried previous suggestion by @ baumannalexj but still the same. The workaround I use is to run Lambda custom resource and trigger the deployment explicitly:
|
We're having the same issue as well :[ |
Sounds like the same as #12417. You will need to manually salt your deployment every time any resource changes. This is a limitation of the Please upvote the feature request for prioritization. |
Here's how to salt your own deployment - const logicalId = // salted id
const cfnDeployment = deployment.node.defaultChild as CfnDeployment;
cfnDeployment.overrideLogicalId(logicalId); The value of the logicalId here should be such that it changes every time a Resource or Method is modified, and this stack must be deployed last. |
Changing the value of the logicalId does not affect the result: One can create a new deployment, but it's impossible to set is as the 'active' deployment for an already-existing stage. |
The deployment is not set as the current one because when you import a So the only workaround I can see is to define your own stages: const api = RestApi.fromRestApiAttributes(this, 'api', {...});
const deployment = new Deployment(this, 'deployment', { api });
const logicalId = // salted id
const cfnDeployment = deployment.node.defaultChild as CfnDeployment;
cfnDeployment.overrideLogicalId(logicalId);
new Stage(this, 'stage', {
stageName: 'stage-created-by-cdk', // this stage will have the new deployment. Others will stay the same
deployment,
}); |
@otaviomacedo So just to sum up there is no way to set the Deployments to the current stage if the RestApi is imported using CDK? FYI, I'm able to set the current deployment using the console |
That's right. |
|
Any news on this topic? |
@otaviomacedo, @hassanazharkhan, @nija-at, @NGL321 et al - I have a similar related unresolved issue - per this it seem a way to deploy to an existing stage is via However in dotnet/C# this property is not accessible. I also note that Stage.FromStageAttributes per the CDK dotnet documentation does not seem to exist, at least in version 2.43.1, not that this would help but a divergence of assembly vs documentation. I'm essentially importing the RestApi into a number of different stacks via I need to redeploy the same stage each time but get the error |
Why this topic was closed? This issue seems to be still a valid request for the feature of imported RestApi. |
@minhhuynh-smg I’d tagged team members per the bot instructions to no avail. Someone probably need to “open new issue referencing this one” |
Wondering if anyone has ever got a working solution for this problem as We are currently experiencing the same issue. One thing i noticed though, looking at the deployment history it seems that it always points to the latest deployment but my changes on the api resources and methods are not working when i test the endpoints. (I will either have to manually do deploy in aws console UI or do cdk deploy twice to make it work) const deployment = new apigateway.Deployment(
scope,
'Deployment',
{
api: restApi,
}
);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
deployment.resource.stageName = 'main';
const logicalId = Date.now().toString(); // salted id
deployment.addToLogicalId(logicalId); UPDATE : deployment.node.addDependency(resource); somehow this solves my issue, my changes is now being deployed and reflecting as soon as the cdk deploy is completed. Here is the complete code: const resource = apigateway.Resource.fromResourceAttributes( .....
const deployment = new apigateway.Deployment(
scope,
'Deployment',
{
api: restApi,
}
);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
deployment.resource.stageName = 'main';
const logicalId = Date.now().toString(); // salted id
deployment.addToLogicalId(logicalId);
deployment.node.addDependency(resource); |
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);
|
@jmihalich agreed all around...TF CDK (or pulumi) looks better every day - since feet is all we have! Will try your approach out! |
For anyone who might have the same problem: after some experimenting, just modifying the code:
|
I've imported from a serverless project this restApi.
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.
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
The text was updated successfully, but these errors were encountered: