Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway RestAPI CloudFormation update does not update Deployment resource

When I update a RestApi resource using CloudFormation update-stack, it does not update the corresponding Deployment resource.

My initial stack looks like this

   Resources :
      RestApi 
         /create
         /delete
      Deployment
         DependsOn = RestApi 
         stage = latest

I updated the stack looks like this

Resources :
  RestApi 
     /create
     /delete
     /update
  Deployment
     DependsOn = RestApi 
     StageName = latest

Using AWS cloudformation update-stack the RestApi is updated but deployment is not updated. I have to manually went in Console and Redeploy the API with the same StageName. Is it a known issue?

like image 874
MichaelW Avatar asked Mar 13 '17 13:03

MichaelW


People also ask

How do I force CloudFormation to update?

In the AWS CloudFormation console , from the list of stacks, select the running stack that you want to update. In the stack details pane, choose Update. If you haven't modified the stack template, select Use current template, and then choose Next.

Can CloudFormation update existing resource?

AWS CloudFormation updates the resource without disrupting operation of that resource and without changing the resource's physical ID. For example, if you update certain properties on an AWS::CloudTrail::Trail resource, AWS CloudFormation updates the trail without disruption.

What happens when a CloudFormation stack is updated?

When you directly update a stack, you submit changes and AWS CloudFormation immediately deploys them. Use direct updates when you want to quickly deploy your updates. With change sets, you can preview the changes AWS CloudFormation will make to your stack, and then decide whether to apply those changes.


1 Answers

This is a known issue with cloudformation. Its frequently discussed on the forum https://forums.aws.amazon.com/message.jspa?messageID=718403#718403

You can create a stage resource separately (not within a deployment resource) and then reference the latest deployment

Stage:
   Deployment: Ref Deployment1
Deployment1:
   RefApiId: RestApi

then when you update the configuration you can add a new deployment. This will associate the latest changes with the stage.

Stage:
   Deployment: Ref Deployment2
Deployment2:
   RefApiId: RestApi

Note that you still need to use the DependsOn field to wire them up correctly.

like image 133
Abhigna Nagaraja Avatar answered Oct 22 '22 03:10

Abhigna Nagaraja