Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudformation: CommaDelimitedList of Cert ARNs for ListenerCertificate Resource

I am trying to pass in a CommaDelimitedList to populate a List of Certs in a AWS::ElasticLoadBalancingV2::ListenerCertificate resource.

Error: Value of property Certificates must be a list of objects

I tried a few formats, including the following:

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

Apparently Cfn is not smart enough to prepend each item with CertificateArn:.

I have also tried combinations of !Split, !Sub, and !Join which gave the same error. Currently I am having to key in the certs directly, which is not viable. While I could create individual parameters for each cert, or use a !Select to grab them out of the list, I don't know how many I will have in each environment (DEV/TEST/PROD).

I know this works cleanly for things like security groups; am I missing something?

Thanks in advance!

like image 343
user2253884 Avatar asked Sep 10 '25 15:09

user2253884


1 Answers

The format of AWS::ElasticLoadBalancingV2::ListenerCertificate Certificate is:

  Certificates: 
    - CertificateArn: String

Non of your uses will work with that. In fact, nothing will work, as this would require looping, which is not supported by CloudFormation. The only feasibale way to achieve what you want is by developing your own custom CFN macro.

Alliteratively, if you will be requiring a lot of iteration in your CFN code, maybe CFN is not the right tool for you. Have a look at CDK or terraform which have rich support for loops.

like image 63
Marcin Avatar answered Sep 13 '25 05:09

Marcin