Repository: zalando-stups/senza

Issue:
ELB should have Scheme "internal" if "Scheme" is not defined
The ELB "Scheme" property should default to "internal" if it's not set.

Discussion:

Patch:
diff --git a/senza/components/elastic_load_balancer.py b/senza/components/elastic_load_balancer.py
index fcaff24..74c10c5 100644
--- a/senza/components/elastic_load_balancer.py
+++ b/senza/components/elastic_load_balancer.py
@@ -164,6 +164,7 @@ def component_elastic_load_balancer(definition,
     definition["Resources"][lb_name] = {
         "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
         "Properties": {
+            "Scheme": loadbalancer_scheme,
             "Subnets": {"Fn::FindInMap": [loadbalancer_subnet_map, {"Ref": "AWS::Region"}, "Subnets"]},
             "HealthCheck": {
                 "HealthyThreshold": "2",


Test patch:
diff --git a/tests/test_components.py b/tests/test_components.py
index 207fca2..651b318 100644
--- a/tests/test_components.py
+++ b/tests/test_components.py
@@ -13,6 +13,7 @@ from senza.components.auto_scaling_group import (component_auto_scaling_group,
                                                  to_iso8601_duration)
 from senza.components.elastic_load_balancer import (component_elastic_load_balancer,
                                                     get_load_balancer_name)
+from senza.components.elastic_load_balancer_v2 import component_elastic_load_balancer_v2
 from senza.components.iam_role import component_iam_role, get_merged_policies
 from senza.components.redis_cluster import component_redis_cluster
 from senza.components.redis_node import component_redis_node
@@ -976,3 +977,43 @@ def test_max_description_length():
     component_configuration(definition, configuration, args, info, False, AccountArguments('dummyregion'))
     assert definition['Description'].startswith('My Stack (Param1: my param value, SecondParam: 1234567890')
     assert 0 < len(definition['Description']) <= 1024
+
+
+def test_component_load_balancer_default_internal_scheme(monkeypatch):
+    configuration = {
+        "Name": "test_lb",
+        "SecurityGroups": "",
+        "HTTPPort": "9999"
+    }
+    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
+    definition = {"Resources": {}}
+
+    args = MagicMock()
+    args.region = "foo"
+
+    mock_string_result = MagicMock()
+    mock_string_result.return_value = "foo"
+    monkeypatch.setattr('senza.components.elastic_load_balancer.resolve_security_groups', mock_string_result)
+
+    result = component_elastic_load_balancer(definition, configuration, args, info, False, MagicMock())
+    assert 'internal' == result["Resources"]["test_lb"]["Properties"]["Scheme"]
+
+
+def test_component_load_balancer_v2_default_internal_scheme(monkeypatch):
+    configuration = {
+        "Name": "test_lb",
+        "SecurityGroups": "",
+        "HTTPPort": "9999"
+    }
+    info = {'StackName': 'foobar', 'StackVersion': '0.1'}
+    definition = {"Resources": {}}
+
+    args = MagicMock()
+    args.region = "foo"
+
+    mock_string_result = MagicMock()
+    mock_string_result.return_value = "foo"
+    monkeypatch.setattr('senza.components.elastic_load_balancer_v2.resolve_security_groups', mock_string_result)
+
+    result = component_elastic_load_balancer_v2(definition, configuration, args, info, False, MagicMock())
+    assert 'internal' == result["Resources"]["test_lb"]["Properties"]["Scheme"]