Cloudformation: CommaDelimitedList of Cert ARNs for Listener



我试图通过CommaDelimitedList来填充AWS::ElasticLoadBalancingV2::ListenerCertificate资源中的证书列表。

错误:属性Certificates的值必须是一个对象列表

我尝试了几种格式,包括:

Parameters:
  pAdditionalAlbListenerCertArns:
    Type: CommaDelimitedList
    Default: "arn:someCert1, arnsomeCert2"
    Description: enter list of the ACM Certificates (Arns)
## Resource Format 1 - I would think this way would work as the result is [thing1, thing2]
Resources:
rCertificatesList:
    Type: AWS::ElasticLoadBalancingV2::ListenerCertificate
    Properties:
      Certificates: ! Ref  pAdditionalAlbListenerCertArns
## Resource Format 2 - I know this should not work, because it's a single item trying to be populated by a list.
Resources:
rCertificatesList:
    Type: AWS::ElasticLoadBalancingV2::ListenerCertificate
    Properties:
      Certificates: 
        CertificateArn: ! Ref  pAdditionalAlbListenerCertArns

显然Cfn不够聪明,不能在每个条目前加上CertificateArn:

我还尝试了!Split, !Sub!Join的组合,它们给出了相同的错误。目前我必须直接输入证书,这是不可行的。虽然我可以为每个证书创建单独的参数,或者使用!Select将它们从列表中抓取出来,但我不知道在每个环境(DEV/TEST/PROD)中将有多少个参数。

我知道这对安全组这样的东西很有效;我错过什么了吗?

提前感谢!

"AWS::ElasticLoadBalancingV2::ListenerCertificate Certificate"的格式为:

  Certificates: 
    - CertificateArn: String

你的所有用途都不能使用它。实际上,什么都不起作用,因为这需要循环,而不支持CloudFormation。实现目标的唯一可行方法是开发自己的自定义CFN宏。

反过来说,如果您需要在CFN代码中进行大量迭代,那么CFN可能不适合您。看看CDK或terraform,它们对循环有丰富的支持。

最新更新