当默认参数更改时,Cloudformation 不会部署更改

Cloudformation won't deploy changes when default param is changed

我有这个模板:

Parameters:
  ALBPort:
    Type: Number
    Description: The loab balancer port (how the app is accessed externally)
    Default: 8000 #changing this
  ...

Resources:
  ALBListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    DependsOn: MyALB
    Properties:
      DefaultActions:
      - Type: forward
        TargetGroupArn: !Ref TargetGroup
      LoadBalancerArn: !Ref MyALB
      Port: !Ref ALBPort #changing this
      Protocol: HTTP

我更改了模板中的默认值,但是当我重新部署时:

No changes to deploy. Stack mystack is up to date

如果我像 Port: 8001 那样静态更改它,CF 会看到更改

更改默认参数值不会更改堆栈中的现有参数值(如果参数已经有值)。默认值仅在您第一次在堆栈中引入参数时应用(在堆栈创建期间或在后续更新中添加新参数时)。之后,您需要在更新期间显式设置参数值。

在您重新部署时,堆栈已将参数 ALBPort 设置为先前的默认值。因此,您的新默认值只会在您使用模板创建新堆栈时应用。您需要在堆栈更新操作期间将 ALBPort 的值设置为您的新值。