Search code examples
amazon-web-servicesaws-cloudformationamazon-elbaws-application-load-balanceraws-cloudformation-custom-resource

CloudFormation Elastic load balancer listener circular dependency with listener certificate


I have a cloudformation template that is trying to create an application load balancer listener and it also attempts to create a listener certificate. The issue is both resources reference each other. I get a circular dependency error when validating the yaml configuration...

#APPLICATION LOAD BALANCER LISTENER
  ApplicationLoadBalancerListener:
    Type: AWS::ElasticLoadBalancingV2::Listener
    Properties: 
      AlpnPolicy: 
        - String
      Certificates: 
        - !Ref ListenerCertificate
      DefaultActions: 
        - Action
      LoadBalancerArn: 
        Ref: ApplicationLoadBalancer
      Port: 443
      Protocol: HTTPS
      SslPolicy: ELBSecurityPolicy-2016-08
  
#APPLICATION LOAD BALANCER LISTENER SSL LINK
  ListenerCertificate:
    Type: AWS::ElasticLoadBalancingV2::ListenerCertificate
    Properties: 
      Certificates: 
        - !Ref SSLCertificate
      ListenerArn:
        Ref: ApplicationLoadBalancerListener

Solution

  • The Certificates shoud be ARN of certificate from ACM, AWS::CertificateManager::Certificate, not your ListenerCertificate.