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

查看:29
本文介绍了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天全站免登陆