【问题标题】:AWS API Gateway RestAPI CloudFormation update does not update Deployment resourceAWS API Gateway RestAPI CloudFormation 更新不更新部署资源
【发布时间】:2017-08-03 12:34:34
【问题描述】:

当我使用 CloudFormation 更新堆栈更新 RestApi 资源时,它不会更新相应的部署资源。

我的初始堆栈如下所示

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

我更新堆栈看起来像这样

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

使用 AWS cloudformation update-stack 更新 RestApi 但不更新部署。我必须手动进入控制台并使用相同的 StageName 重新部署 API。这是一个已知问题吗?

【问题讨论】:

    标签: amazon-web-services swagger aws-api-gateway amazon-cloudformation


    【解决方案1】:

    这是 cloudformation 的一个已知问题。论坛上经常讨论的https://forums.aws.amazon.com/message.jspa?messageID=718403#718403

    您可以单独创建阶段资源(不在部署资源内),然后引用最新的部署

    Stage:
       Deployment: Ref Deployment1
    Deployment1:
       RefApiId: RestApi
    

    然后,当您更新配置时,您可以添加新部署。这会将最新的更改与阶段相关联。

    Stage:
       Deployment: Ref Deployment2
    Deployment2:
       RefApiId: RestApi
    

    请注意,您仍然需要使用 DependsOn 字段来正确连接它们。

    【讨论】:

    • 感谢您的反馈。使用这种方法,我认为每次更新都需要为 Stage 资源使用不同的 StageName。否则,cloudformation 将无法识别更改。然后您的网关 URL 将更改每次更新(除非我们使用自定义域)。
    • 您的网址不应更改。这将导致 cloudformation 创建新部署并将其与现有阶段相关联。
    猜你喜欢
    • 1970-01-01
    • 2018-05-25
    • 1970-01-01
    • 2019-07-12
    • 1970-01-01
    • 2020-04-10
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    相关资源
    最近更新 更多