diff --git a/application-loadbalancer.cfndsl.rb b/application-loadbalancer.cfndsl.rb index 4bfdcfb..d59ada7 100644 --- a/application-loadbalancer.cfndsl.rb +++ b/application-loadbalancer.cfndsl.rb @@ -85,7 +85,7 @@ listeners = external_parameters.fetch(:listeners, {}) listeners.each do |listener_name, listener| - next if listener.nil? + next if listener.nil? || (listener.has_key?('enabled') && listener['enabled'] == false) ElasticLoadBalancingV2_Listener("#{listener_name}Listener") do Protocol listener['protocol'].upcase diff --git a/tests/disable_listener.test.yaml b/tests/disable_listener.test.yaml new file mode 100644 index 0000000..9815b1b --- /dev/null +++ b/tests/disable_listener.test.yaml @@ -0,0 +1,49 @@ +test_metadata: + type: config + name: disable_listener + description: disable a configured listener + +targetgroups: + www: + protocol: http + port: 80 + healthcheck: + port: 8080 + protocol: http + interval: 30 + timeout: 10 + healthy_count: 2 + unhealthy_count: 5 + path: /healthcheck + code: 200 + attributes: + stickiness.enabled: true + stickiness.type: lb_cookie + stickiness.lb_cookie.duration_seconds: 604800 + tags: + Name: www + api: + protocol: http + port: 80 + healthcheck: + path: /ping + code: 200 + +listeners: + http: + enabled: false + port: 80 + protocol: http + default: + action: + redirect: http_to_https + https: + port: 443 + protocol: https + ssl_policy: ELBSecurityPolicy-TLS-1-2-Ext-2018-06 + default: + certificate: website + action: + targetgroup: www + certificates: + - api \ No newline at end of file