Merge "Allow to define Load Balancer schema (i.e. internal vs internet facing)"
diff --git a/Secrets.md b/Secrets.md
index 962b84a..5c3a3ef 100644
--- a/Secrets.md
+++ b/Secrets.md
@@ -65,7 +65,8 @@
 ### LDAP Password
 
 You will need to put the admin LDAP password in a file called `ldapPassword`
-in the same directory of the SSH keys (e.g. `/tmp/secrets`).
+in the same directory of the SSH keys (e.g. `/tmp/secrets`). Password should be put in the
+plain text without quotes. If password contains quotes, they should be escaped (e.g aa\"bb)
 
 ### SMTP Password
 
diff --git a/dual-master/Makefile b/dual-master/Makefile
index f7e94fc..203e0f3 100644
--- a/dual-master/Makefile
+++ b/dual-master/Makefile
@@ -38,6 +38,7 @@
 		--parameters \
 		ParameterKey=DesiredCapacity,ParameterValue=$(CLUSTER_DESIRED_CAPACITY) \
 		ParameterKey=ECSKeyName,ParameterValue=$(CLUSTER_KEYS) \
+		ParameterKey=TemplateBucketName,ParameterValue=$(TEMPLATE_BUCKET_NAME) \
 		ParameterKey=InternetGatewayIdProp,ParameterValue=$(INTERNET_GATEWAY_ID) \
 		ParameterKey=VPCIdProp,ParameterValue=$(VPC_ID) \
 		ParameterKey=SubnetIdProp,ParameterValue=$(SUBNET_ID) \
diff --git a/dual-master/cf-cluster.yml b/dual-master/cf-cluster.yml
index 6eec872..07b4cc2 100644
--- a/dual-master/cf-cluster.yml
+++ b/dual-master/cf-cluster.yml
@@ -3,6 +3,9 @@
              hosts using Elastic Container Service. This stack runs containers on
              hosts that are in a public VPC subnet.
 Parameters:
+  TemplateBucketName:
+    Description: S3 bucket containing cloudformation templates
+    Type: String
   DesiredCapacity:
     Type: Number
     Default: '1'
@@ -260,7 +263,7 @@
   ECSTaskNetworkStack:
     Type: AWS::CloudFormation::Stack
     Properties:
-      TemplateURL: https://aws-gerrit-cf-templates.s3.amazonaws.com/cf-gerrit-network-stack.yml
+      TemplateURL: !Join [ '', ['https://', !Ref TemplateBucketName, '.s3.amazonaws.com/cf-gerrit-network-stack.yml'] ]
       TimeoutInMinutes: '25'
       Parameters:
         InternetGatewayIdProp: !Ref 'InternetGatewayIdProp'
diff --git a/gerrit/etc/secure.config.template b/gerrit/etc/secure.config.template
index f05c0ca..143aaf2 100644
--- a/gerrit/etc/secure.config.template
+++ b/gerrit/etc/secure.config.template
@@ -1,6 +1,6 @@
 [auth]
 	registerEmailPrivateKey = {{ REGISTER_EMAIL_PRIVATE_KEY }}
 [ldap]
-	password = {{ LDAP_PASSWORD }}
+	password = "{{ LDAP_PASSWORD }}"
 [sendemail]
   smtpPass = {{ SMTP_PASSWORD }}
diff --git a/master-slave/Makefile b/master-slave/Makefile
index cd4bb66..525dd40 100644
--- a/master-slave/Makefile
+++ b/master-slave/Makefile
@@ -35,6 +35,7 @@
 		--parameters \
 		ParameterKey=DesiredCapacity,ParameterValue=$(CLUSTER_DESIRED_CAPACITY) \
 		ParameterKey=ECSKeyName,ParameterValue=$(CLUSTER_KEYS) \
+		ParameterKey=TemplateBucketName,ParameterValue=$(TEMPLATE_BUCKET_NAME) \
 		ParameterKey=InternetGatewayIdProp,ParameterValue=$(INTERNET_GATEWAY_ID) \
 		ParameterKey=VPCIdProp,ParameterValue=$(VPC_ID) \
 		ParameterKey=SubnetIdProp,ParameterValue=$(SUBNET_ID) \
diff --git a/master-slave/cf-cluster.yml b/master-slave/cf-cluster.yml
index c3c64f0..c7a4a0e 100644
--- a/master-slave/cf-cluster.yml
+++ b/master-slave/cf-cluster.yml
@@ -3,6 +3,9 @@
              hosts using Elastic Container Service. This stack runs containers on
              hosts that are in a public VPC subnet.
 Parameters:
+  TemplateBucketName:
+    Description: S3 bucket containing cloudformation templates
+    Type: String
   DesiredCapacity:
     Type: Number
     Default: '1'
@@ -204,7 +207,7 @@
   ECSTaskNetworkStack:
     Type: AWS::CloudFormation::Stack
     Properties:
-      TemplateURL: https://aws-gerrit-cf-templates.s3.amazonaws.com/cf-gerrit-network-stack.yml
+      TemplateURL: !Join [ '', ['https://', !Ref TemplateBucketName, '.s3.amazonaws.com/cf-gerrit-network-stack.yml'] ]
       TimeoutInMinutes: '25'
       Parameters:
         InternetGatewayIdProp: !Ref 'InternetGatewayIdProp'
diff --git a/single-master/Makefile b/single-master/Makefile
index d77dde3..d7b6051 100644
--- a/single-master/Makefile
+++ b/single-master/Makefile
@@ -31,6 +31,7 @@
 		--region $(AWS_REGION) \
 		--parameters \
 		ParameterKey=ECSKeyName,ParameterValue=$(CLUSTER_KEYS) \
+		ParameterKey=TemplateBucketName,ParameterValue=$(TEMPLATE_BUCKET_NAME) \
 		ParameterKey=InternetGatewayIdProp,ParameterValue=$(INTERNET_GATEWAY_ID) \
 		ParameterKey=VPCIdProp,ParameterValue=$(VPC_ID) \
 		ParameterKey=SubnetIdProp,ParameterValue=$(SUBNET_ID) \
diff --git a/single-master/cf-cluster.yml b/single-master/cf-cluster.yml
index 239ed31..a436035 100644
--- a/single-master/cf-cluster.yml
+++ b/single-master/cf-cluster.yml
@@ -3,6 +3,9 @@
              hosts using Elastic Container Service. This stack runs containers on
              hosts that are in a public VPC subnet.
 Parameters:
+  TemplateBucketName:
+    Description: S3 bucket containing cloudformation templates
+    Type: String
   DesiredCapacity:
     Type: Number
     Default: '1'
@@ -180,7 +183,7 @@
   ECSTaskNetworkStack:
     Type: AWS::CloudFormation::Stack
     Properties:
-      TemplateURL: https://aws-gerrit-cf-templates.s3.amazonaws.com/cf-gerrit-network-stack.yml
+      TemplateURL: !Join [ '', ['https://', !Ref TemplateBucketName, '.s3.amazonaws.com/cf-gerrit-network-stack.yml'] ]
       TimeoutInMinutes: '25'
       Parameters:
         InternetGatewayIdProp: !Ref 'InternetGatewayIdProp'
diff --git a/single-master/cf-service.yml b/single-master/cf-service.yml
index 60a9728..cc8530c 100644
--- a/single-master/cf-service.yml
+++ b/single-master/cf-service.yml
@@ -307,7 +307,7 @@
     ECSTaskExecutionRoleStack:
       Type: AWS::CloudFormation::Stack
       Properties:
-        TemplateURL: https://aws-gerrit-cf-templates.s3.amazonaws.com/cf-gerrit-task-execution-role.yml
+        TemplateURL: !Join [ '', ['https://', !Ref TemplateBucketName, '.s3.amazonaws.com/cf-gerrit-task-execution-role.yml'] ]
         TimeoutInMinutes: '5'
 
 Outputs: