Allow to define Load Balancer scheme for master and slave service (i.e.
internal vs internet facing)

Some organisations do not use Internet Gateways. In that case Load
Balancer schema can be only internal.

Feature: Issue 13179
Change-Id: I6d341d75f4548443edd3344376cb4bcbcb204e0c
diff --git a/dual-master/Makefile b/dual-master/Makefile
index 71bd251..d7ec7f7 100644
--- a/dual-master/Makefile
+++ b/dual-master/Makefile
@@ -71,6 +71,9 @@
 ifdef LDAP_ACCOUNT_PATTERN
 		$(eval MASTER1_SERVICE_OPTIONAL_PARAMS := $(MASTER1_SERVICE_OPTIONAL_PARAMS) ParameterKey=LDAPAccountPattern,ParameterValue=\"$(LDAP_ACCOUNT_PATTERN)\")
 endif
+ifdef LOAD_BALANCER_SCHEME
+		$(eval MASTER1_SERVICE_OPTIONAL_PARAMS := $(MASTER1_SERVICE_OPTIONAL_PARAMS) ParameterKey=LoadBalancerScheme,ParameterValue=$(LOAD_BALANCER_SCHEME))
+endif
 ifdef REMOTE_REPLICATION_TARGET_HOST
 		$(eval REMOTE_OPTIONAL_PARAMS := $(REMOTE_OPTIONAL_PARAMS) ParameterKey=RemoteReplicationTargetHost,ParameterValue=$(REMOTE_REPLICATION_TARGET_HOST))
 endif
@@ -118,6 +121,9 @@
 ifdef LDAP_ACCOUNT_PATTERN
 		$(eval MASTER2_SERVICE_OPTIONAL_PARAMS := $(MASTER2_SERVICE_OPTIONAL_PARAMS) ParameterKey=LDAPAccountPattern,ParameterValue=\"$(LDAP_ACCOUNT_PATTERN)\")
 endif
+ifdef LOAD_BALANCER_SCHEME
+		$(eval MASTER2_SERVICE_OPTIONAL_PARAMS := $(MASTER2_SERVICE_OPTIONAL_PARAMS) ParameterKey=LoadBalancerScheme,ParameterValue=$(LOAD_BALANCER_SCHEME))
+endif
 ifdef REMOTE_REPLICATION_TARGET_HOST
 		$(eval REMOTE_OPTIONAL_PARAMS := $(REMOTE_OPTIONAL_PARAMS) ParameterKey=RemoteReplicationTargetHost,ParameterValue=$(REMOTE_REPLICATION_TARGET_HOST))
 endif
@@ -182,6 +188,9 @@
 ifdef LDAP_ACCOUNT_PATTERN
 		$(eval SLAVE_SERVICE_OPTIONAL_PARAMS := $(SLAVE_SERVICE_OPTIONAL_PARAMS) ParameterKey=LDAPAccountPattern,ParameterValue=\"$(LDAP_ACCOUNT_PATTERN)\")
 endif
+ifdef LOAD_BALANCER_SCHEME
+		$(eval SLAVE_SERVICE_OPTIONAL_PARAMS := $(SLAVE_SERVICE_OPTIONAL_PARAMS) ParameterKey=LoadBalancerScheme,ParameterValue=$(LOAD_BALANCER_SCHEME))
+endif
 
 	$(AWS_FC_COMMAND) create-stack \
 		--stack-name $(SERVICE_SLAVE_STACK_NAME) \
diff --git a/dual-master/cf-service-master.yml b/dual-master/cf-service-master.yml
index ccee40a..77c867f 100644
--- a/dual-master/cf-service-master.yml
+++ b/dual-master/cf-service-master.yml
@@ -47,6 +47,11 @@
   LBSubdomain:
         Description: The subdomain of the Gerrit load balancer
         Type: String
+  LoadBalancerScheme:
+        Description: Load Balancer scheme, the nodes of an internet-facing load balancer have public IP addresses.
+        Type: String
+        Default: internet-facing
+        AllowedValues: [internal, internet-facing]
   GerritKeyPrefix:
         Description: Gerrit credentials keys prefix
         Type: String
@@ -363,7 +368,7 @@
         Type: AWS::ElasticLoadBalancingV2::LoadBalancer
         Properties:
             Type: network
-            Scheme: internet-facing
+            Scheme: !Ref 'LoadBalancerScheme'
             Subnets:
               - Fn::ImportValue:
                   !Join [':', [!Ref 'ClusterStackName', 'PublicSubnetOne']]
diff --git a/dual-master/cf-service-slave.yml b/dual-master/cf-service-slave.yml
index a68e916..9d4aa7d 100644
--- a/dual-master/cf-service-slave.yml
+++ b/dual-master/cf-service-slave.yml
@@ -82,6 +82,11 @@
       Description: The subdomain of the Gerrit cluster
       Type: String
       Default: gerrit-slave-demo
+  LoadBalancerScheme:
+        Description: Load Balancer schema, The nodes of an Internet-facing load balancer have public IP addresses.
+        Type: String
+        Default: internet-facing
+        AllowedValues: [internal, internet-facing]
   GerritGitVolume:
       Description: Gerrit git volume name
       Type: String
@@ -365,7 +370,7 @@
         Type: AWS::ElasticLoadBalancingV2::LoadBalancer
         Properties:
             Type: network
-            Scheme: internet-facing
+            Scheme: !Ref 'LoadBalancerScheme'
             Subnets:
               - Fn::ImportValue:
                   !Join [':', [!Ref 'ClusterStackName', 'PublicSubnetOne']]