CloudFormation doesn't deploy to API gateway stages on update

后端 未结 8 1310
南笙
南笙 2020-12-25 11:47

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

8条回答
  •  感动是毒
    2020-12-25 12:06

    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 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html).

    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: http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_DescribeStackEvents.html

    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.

提交回复
热议问题