微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Cloudformation:用于 ListenerCertificate 资源的证书 ARN 的逗号分隔列表

如何解决Cloudformation:用于 ListenerCertificate 资源的证书 ARN 的逗号分隔列表

我正在尝试传入 CommaDelimitedList 以填充 AWS::ElasticLoadBalancingV2::ListenerCertificate 资源中的证书列表。

错误属性证书的值必须是对象列表

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

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 不支持。实现您想要的唯一可行方法是开发您自己的 custom CFN macro

换句话说,如果您需要在 CFN 代码中进行大量迭代,那么 CFN 可能不是适合您的工具。看看对循环有丰富支持的 CDK 或 terraform。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。