0
for listener in listeners:
                    listener_arn = listener['ListenerArn']
                    protocol = listener['Protocol']
                    port = listener['Port']
                    certificates = listener.get('Certificates', [])

                    if not certificates:
                        writer.writerow({
                            '#' : i, 
                            'LoadBalancerName': load_balancer_name,
                            'LoadBalancerARN': load_balancer_arn,
                            'Status': status,
                            'Type' : type,
                            'ListenerARN' : listener_arn,
                            'Protocol': protocol,
                            'Port': port,
                            'CertificateARN': 'NA',
                            #'Default': 'NA'
                        })
                    else:
                        for certificate in certificates:
                            certificate_arn = certificate['CertificateArn']
                            is_default = certificate.get('IsDefault',False)

                            writer.writerow({
                            '#' : i, 
                            'LoadBalancerName': load_balancer_name,
                            'LoadBalancerARN': load_balancer_arn,
                            'Status': status,
                            'Type' : type,
                            'ListenerARN' : listener_arn,
                            'Protocol': protocol,
                            'Port': port,
                            'CertificateARN': certificate_arn,
                            'Default': is_default,
                            })

Based on the snippet above, it only lists down the default certificate. Another problem is, though it is default (I've cross-checked it), it still returns False for the IsDefault.

I have tried using describe_listener_certificates() but it's giving me KeyError. What I'm expecting to have is:

  1. default certificate that is recognized as IsDefault = True
  2. additional listener certificates for SNI that is recognized as IsDefault = False

0 Answers0