CloudFormation在更新时不会部署到API网关阶段 [英] CloudFormation doesn't deploy to API gateway stages on update

查看:84
本文介绍了CloudFormation在更新时不会部署到API网关阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用带有API Gateway资源的模板运行CloudFormation deploy 时,我第一次运行它时,它会创建并部署到各个阶段。以后我运行它时,它会更新资源,但不会部署到各个阶段。

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提到了类似的问题: https://github.com/hashicorp/terraform/issues/6613

(Terraform mentions a similar issue: https://github.com/hashicorp/terraform/issues/6613)

推荐答案

似乎只要您的Cloudformation资源之一发生更改,就无法轻松创建新的部署。

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

一种工作方式解决方法是使用Lambda支持的自定义资源(请参见 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html )。

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).

仅当您的资源之一已更新时,Lambda才应创建新的部署。要确定您的资源之一是否已更新,

,您可能必须围绕此API调用实现自定义逻辑: http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_DescribeStackEvents.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

为了触发自定义资源的更新,建议您提供一个Cloudformation参数,该参数将用于强制自定义资源的更新(例如,当前时间或版本号)。

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).

请注意,您必须在自定义资源中添加一个 DependsOn 子句,该子句将包含与您的所有相关资源API。否则,可能会在更新所有API资源之前创建部署。

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.

希望这会有所帮助。

这篇关于CloudFormation在更新时不会部署到API网关阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆