CloudFormation doesn't deploy to API gateway stages on update

When I run CloudFormation deploy using a template with API Gateway resources, the first time I run it, it creates and deploys to stages. The subsequent times I run it, it updates the resources but doesn't deploy to stages.

Is that behaviour as intended? If yes, how'd I get it to deploy to stages whenever it updates?

(Terraform mentions a similar issue:

Answers 1

  • Seems like there is no way to easily create a new Deployment whenever one of your Cloudformation Resources changes.

    One way to work around that would be to use a Lambda-backed Custom Resource (see

    The Lambda should create the new Deployment, only if one of your Resources has been updated. To determine if one of your Resources has been updated,
    you will probably have to implement custom logic around this API call:

    In order to trigger updates on your Custom Resource, I suggest you supply a Cloudformation Parameter that will be used to force an update of your Custom Resource (e.g. the current time, or a version number).

    Note that you will have to add a DependsOn clause to your Custom Resource that will include all Resources relevant to your API. Otherwise, your deployment might be created before all your API Resources are updated.

    Hope this helps.

Related Articles