Merge changes I88ecbd32,I5012c15a

* changes:
  Remove haproxy and syslog-sidecar
  Enable dynamodb global-refdb
diff --git a/.gitignore b/.gitignore
index bec44c7..0bf1d7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,5 @@
 gerrit.config
 secure.config
 replication.config
-zookeeper-refdb.config
 .idea
 **/*.pem
diff --git a/Docker.md b/Docker.md
index 98d81dc..f747330 100644
--- a/Docker.md
+++ b/Docker.md
@@ -22,15 +22,13 @@
 publishing a new docker image will _not_ make it available to ECS, so it cannot be used for upgrading running instances.
 
 Note that you will need to _cd_ to the recipe directory before running any of the following and that the relevant image
-needs to exist for that specific recipe (for example you can't publish HAProxy from the single-primary recipe).
+needs to exist for that specific recipe.
 
 * Gerrit: `make gerrit-publish`
 * SSH Agent: `make git-ssh-publish`
 * Gerrit Daemon: `make git-daemon-publish`
 * Grafana: `make grafana-publish`
 * Prometheus: `make prometheus-publish`
-* HAProxy: `make haproxy-publish`
-* Syslog sidecar: `make syslog-sidecar-publish`
 
 
 
diff --git a/Makefile.common b/Makefile.common
index 05f6679..371001e 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -23,6 +23,7 @@
 	aws s3 cp ../common-templates/cf-primary-asg.yml s3://$(TEMPLATE_BUCKET_NAME)/
 	aws s3 cp ../common-templates/cf-efs-stack.yml s3://$(TEMPLATE_BUCKET_NAME)/
 	aws s3 cp ../common-templates/cf-ecs-service-cpu-autoscaling.yml s3://$(TEMPLATE_BUCKET_NAME)/
+	aws s3 cp ../common-templates/cf-dynamodb-stack.yml s3://$(TEMPLATE_BUCKET_NAME)/
 
 set-optional-params-metrics-cloudwatch:
 ifdef METRICS_CLOUDWATCH_ENABLED
@@ -62,10 +63,6 @@
 ifdef MULTISITE_ENABLED
 		$(eval MULTISITE_OPTIONAL_PARAMS := ParameterKey=MultiSiteEnabled,ParameterValue=$(MULTISITE_ENABLED))
 		$(eval MULTISITE_OPTIONAL_PARAMS := $(MULTISITE_OPTIONAL_PARAMS) ParameterKey=MultiSiteKafkaBrokers,ParameterValue=\"$(MULTISITE_KAFKA_BROKERS)\")
-		$(eval MULTISITE_OPTIONAL_PARAMS := $(MULTISITE_OPTIONAL_PARAMS) ParameterKey=MultiSiteZookeeperConnectString,ParameterValue=$(MULTISITE_ZOOKEEPER_CONNECT_STRING))
-endif
-ifdef MULTISITE_ZOOKEEPER_ROOT_NODE
-		$(eval MULTISITE_OPTIONAL_PARAMS := $(MULTISITE_OPTIONAL_PARAMS) ParameterKey=MultiSiteZookeeperRootNode,ParameterValue=$(MULTISITE_ZOOKEEPER_ROOT_NODE))
 endif
 
 set-ldap-account-pattern:
diff --git a/Prerequisites.md b/Prerequisites.md
index 0913f1d..b7327b2 100644
--- a/Prerequisites.md
+++ b/Prerequisites.md
@@ -13,8 +13,6 @@
 aws ecr create-repository --repository-name aws-gerrit/gerrit
 aws ecr create-repository --repository-name aws-gerrit/git-ssh
 aws ecr create-repository --repository-name aws-gerrit/git-daemon
-aws ecr create-repository --repository-name aws-gerrit/haproxy
-aws ecr create-repository --repository-name aws-gerrit/syslog-sidecar
 aws ecr create-repository --repository-name aws-gerrit/prometheus
 aws ecr create-repository --repository-name aws-gerrit/grafana
 aws ecr create-repository --repository-name aws-gerrit/git-gc
diff --git a/common-templates/cf-dynamodb-stack.yml b/common-templates/cf-dynamodb-stack.yml
new file mode 100644
index 0000000..7494aac
--- /dev/null
+++ b/common-templates/cf-dynamodb-stack.yml
@@ -0,0 +1,60 @@
+AWSTemplateFormatVersion: '2010-09-09'
+Description: DynamoDB tables for refs-db validation
+Parameters:
+  DynamoDBLocksTableName:
+    Description: The name of the DynamoDB locks table
+    Type: String
+  DynamoDBRefsTableName:
+    Description: The name of the DynamoDB refs table
+    Type: String
+
+Mappings:
+  DynamoDB:
+    CapacityUnits:
+      Read: 10
+      Write: 10
+
+Resources:
+  RefsDbTable:
+    Type: AWS::DynamoDB::Table
+    Properties:
+      TableName: !Ref DynamoDBRefsTableName
+      AttributeDefinitions:
+        - AttributeName: refPath
+          AttributeType: S
+      KeySchema:
+        - AttributeName: refPath
+          KeyType: HASH
+      ProvisionedThroughput:
+        ReadCapacityUnits: !FindInMap ['DynamoDB', 'CapacityUnits', 'Read']
+        WriteCapacityUnits: !FindInMap ['DynamoDB', 'CapacityUnits', 'Write']
+
+  LocksTable:
+    Type: AWS::DynamoDB::Table
+    Properties:
+      TableName: !Ref DynamoDBLocksTableName
+      AttributeDefinitions:
+        - AttributeName: lockKey
+          AttributeType: S
+        - AttributeName: lockValue
+          AttributeType: S
+      KeySchema:
+        - AttributeName: lockKey
+          KeyType: HASH
+        - AttributeName: lockValue
+          KeyType: RANGE
+      ProvisionedThroughput:
+        ReadCapacityUnits: !FindInMap ['DynamoDB', 'CapacityUnits', 'Read']
+        WriteCapacityUnits: !FindInMap ['DynamoDB', 'CapacityUnits', 'Write']
+
+Outputs:
+  RefsDbTable:
+    Description: The refs-db table
+    Value: !Ref RefsDbTable
+    Export:
+      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'RefsDbTable' ] ]
+  LocksTable:
+    Description: The locks-db table
+    Value: !Ref LocksTable
+    Export:
+      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'LocksTable' ] ]
\ No newline at end of file
diff --git a/common-templates/cf-gerrit-task-execution-role.yml b/common-templates/cf-gerrit-task-execution-role.yml
index 65c0fc7..2c748d0 100644
--- a/common-templates/cf-gerrit-task-execution-role.yml
+++ b/common-templates/cf-gerrit-task-execution-role.yml
@@ -31,6 +31,17 @@
                   - 'logs:PutLogEvents'
                   # Allow the ECS tasks to push metrics to CloudWatch
                   - 'cloudwatch:PutMetricData'
+                  # Allow the ECS tasks to perform CRUD actions to dynamodb table:
+                  # Used for global refs-db operations.
+                  - 'dynamodb:DeleteItem'
+                  - 'dynamodb:CreateTable'
+                  - 'dynamodb:DescribeTable'
+                  - 'dynamodb:GetItem'
+                  - 'dynamodb:ListTables'
+                  - 'dynamodb:PutItem'
+                  - 'dynamodb:Query'
+                  - 'dynamodb:Scan'
+                  - 'dynamodb:UpdateItem'
                 Resource: '*'
           - PolicyName: AmazonECSTaskSecretManagerRolePolicy
             PolicyDocument:
diff --git a/common.env b/common.env
index 225f182..09181cc 100644
--- a/common.env
+++ b/common.env
@@ -18,13 +18,9 @@
 
 # Image directories
 IMAGE_DIR:=$(ROOT_DIR)/gerrit
-HAPROXY_IMAGE_DIR=$(ROOT_DIR)/dual-primary/haproxy
-SYSLOG_IMAGE_DIR=$(ROOT_DIR)/dual-primary/syslog-sidecar
 
 # Image SHA1 versions
 HEAD_SHA1=$(shell find $(IMAGE_DIR) -type f -exec cat {} \; | shasum | cut -c 1-20)
-HAPROXY_HEAD_SHA1=$(shell find $(HAPROXY_IMAGE_DIR) -type f -exec cat {} \; | shasum | cut -c 1-20)
-SYSLOG_HEAD_SHA1=$(shell find $(SYSLOG_IMAGE_DIR) -type f -exec cat {} \; | shasum | cut -c 1-20)
 
 IMAGE_TAG=$(GERRIT_VERSION).$(GERRIT_PATCH)-$(HEAD_SHA1)
 
diff --git a/dual-primary/Makefile b/dual-primary/Makefile
index 9007fe5..56fdaee 100644
--- a/dual-primary/Makefile
+++ b/dual-primary/Makefile
@@ -8,14 +8,16 @@
 SERVICE_REPLICA_TEMPLATE:=cf-service-replica.yml
 DNS_ROUTING_TEMPLATE:=cf-dns-route.yml
 CLOUDWATCH_DASHBOARD_TEMPLATE:=cf-dashboard.yml
-LOAD_BALANCER_TEMPLATE:=cf-service-lb.yml
 SERVICE_REPLICATION_TEMPLATE:=cf-service-replication.yml
 AWS_FC_COMMAND=export AWS_PAGER=;aws cloudformation
 GIT_GC_SOURCE_PATH=/mnt/efs/gerrit-shared/git
 
 SINGLE_SITE_PLUGINS=javamelody high-availability healthcheck metrics-reporter-cloudwatch
 
-MULTI_SITE_PLUGINS=$(SINGLE_SITE_PLUGINS) multi-site kafka-events websession-broker zookeeper-refdb~zk-3.5
+HA_SITE_PLUGINS=$(SINGLE_SITE_PLUGINS) aws-dynamodb-refdb
+HA_SITE_PLUGINS_LIBS_LINKS=high-availability
+
+MULTI_SITE_PLUGINS=$(SINGLE_SITE_PLUGINS) multi-site kafka-events websession-broker
 MULTI_SITE_PLUGINS_LIBS_LINKS=multi-site replication
 MULTI_SITE_MAVEN_LIBS=events-broker~$(EVENTSBROKER_LIB_VER)
 
@@ -24,8 +26,7 @@
 				cluster cluster-keys service-primary-1 service-primary-2 service-replica dns-routing dashboard delete-dashboard\
 				wait-for-cluster-creation wait-for-service-primary-1-creation wait-for-service-primary-2-creation wait-for-service-replica-creation wait-for-dns-routing-creation wait-for-dashboard-creation \
 				wait-for-cluster-deletion wait-for-service-primary-1-deletion wait-for-service-primary-2-deletion wait-for-service-replica-deletion wait-for-dns-routing-deletion wait-for-dashboard-deletion \
-				service-lb wait-for-service-lb-deletion wait-for-service-lb-creation \
-				gerrit-build gerrit-publish haproxy-publish syslog-sidecar-publish
+				gerrit-build gerrit-publish
 
 ifeq ($(REPLICATION_SERVICE_ENABLED),true)
 optional_replication_targets_creation=service-replication wait-for-service-replication-creation
@@ -39,14 +40,13 @@
 
 create-all: upload-common-templates \
 						git-daemon-publish git-ssh-publish \
-						gerrit-publish haproxy-publish syslog-sidecar-publish \
+						gerrit-publish \
 						cluster wait-for-cluster-creation \
 						$(optional_replication_targets_creation) \
 						service-replica service-primary-1 \
 						wait-for-service-primary-1-creation wait-for-service-replica-creation \
 						service-primary-2 wait-for-service-primary-2-creation \
 						$(optional_dashboard_targets_creation) \
-						service-lb wait-for-service-lb-creation \
 						$(optional_git_gc_targets_creation) \
 						dns-routing wait-for-dns-routing-creation
 
@@ -54,7 +54,8 @@
 			set-optional-params-for-replica-filesystem \
 			set-optional-params-for-replica-auto-scaling-capacity \
 			set-optional-params-for-replica-capacity-provider \
-			set-optional-network-params
+			set-optional-network-params \
+			set-optional-refs-db-params
 ifdef CLUSTER_INSTANCE_TYPE
 		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=InstanceType,ParameterValue=$(CLUSTER_INSTANCE_TYPE))
 endif
@@ -67,18 +68,15 @@
 ifdef PRIMARY_FILESYSTEM_ID
 		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=PrimaryFileSystemID,ParameterValue=$(PRIMARY_FILESYSTEM_ID))
 endif
-ifdef HA_PROXY_MAX_COUNT
-		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=HAProxyMaxCount,ParameterValue=$(HA_PROXY_MAX_COUNT))
-endif
-ifdef HA_PROXY_DESIRED_COUNT
-		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=HAProxyDesiredCount,ParameterValue=$(HA_PROXY_DESIRED_COUNT))
-endif
 ifdef PRIMARY_MAX_COUNT
 		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=PrimaryMaxCount,ParameterValue=$(PRIMARY_MAX_COUNT))
 endif
 ifdef LOAD_BALANCER_SCHEME
 		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=PrimariesGerritLoadBalancerScheme,ParameterValue=$(LOAD_BALANCER_SCHEME))
 endif
+ifdef CREATE_REFS_DB_TABLES
+		$(eval CLUSTER_OPTIONAL_PARAMS := $(CLUSTER_OPTIONAL_PARAMS) ParameterKey=CreateRefsDBTables,ParameterValue=$(CREATE_REFS_DB_TABLES))
+endif
 
 	$(AWS_FC_COMMAND) create-stack \
 		--stack-name $(CLUSTER_STACK_NAME) \
@@ -94,12 +92,14 @@
 		$(GERRIT_OPTIONAL_PRIMARY_VOLUME) \
 		$(GERRIT_OPTIONAL_PARAMS_REPLICA_FILESYSTEM) \
 		$(GERRIT_OPTIONAL_PARAMS_REPLICA_AUTO_SCALING_CAPACITY) \
-		$(GERRIT_OPTIONAL_PARAMS_REPLICA_CAPACITY_PROVIDER)
+		$(GERRIT_OPTIONAL_PARAMS_REPLICA_CAPACITY_PROVIDER) \
+		$(REFS_DB_OPTIONAL_PARAMS)
 
 service-primary-1: set-optional-params-metrics-cloudwatch set-optional-params-smtp \
 					set-optional-params-multisite set-ldap-account-pattern \
 					set-optional-gerrit-ulimits set-optional-jgit-conf \
-					set-high-availability-optional-params
+					set-high-availability-optional-params \
+					set-optional-refs-db-params
 ifdef GERRIT_PRIMARY1_INSTANCE_ID
 		$(eval PRIMARY1_SERVICE_OPTIONAL_PARAMS := $(PRIMARY1_SERVICE_OPTIONAL_PARAMS) ParameterKey=InstanceId,ParameterValue=$(GERRIT_PRIMARY1_INSTANCE_ID))
 endif
@@ -137,7 +137,7 @@
 		ParameterKey=GerritKeyPrefix,ParameterValue=$(GERRIT_KEY_PREFIX)\
 		ParameterKey=DockerImage,ParameterValue=aws-gerrit/gerrit:$(IMAGE_TAG) \
 		ParameterKey=PeerSubdomain,ParameterValue=$(PRIMARY2_SUBDOMAIN) \
-		ParameterKey=LBSubdomain,ParameterValue=$(LB_SUBDOMAIN) \
+		ParameterKey=PrimariesGerritSubdomain,ParameterValue=$(PRIMARIES_GERRIT_SUBDOMAIN) \
 		ParameterKey=GerritRAM,ParameterValue=$(GERRIT_RAM) \
 		ParameterKey=GerritCPU,ParameterValue=$(GERRIT_CPU) \
 		ParameterKey=GerritHeapLimit,ParameterValue=$(GERRIT_HEAP_LIMIT) \
@@ -150,12 +150,14 @@
 		$(LDAP_ACCOUNT_PATTERN_PARAM) \
 		$(METRICS_CW_OPTIONAL_PARAMS) \
 		$(SMTP_OPTIONAL_PARAMS) \
-		$(GERRIT_ULIMITS)
+		$(GERRIT_ULIMITS) \
+		$(REFS_DB_OPTIONAL_PARAMS)
 
 service-primary-2: set-optional-params-metrics-cloudwatch set-optional-params-smtp \
 					set-optional-params-multisite set-ldap-account-pattern \
 					set-optional-gerrit-ulimits set-optional-jgit-conf \
-					set-high-availability-optional-params
+					set-high-availability-optional-params \
+					set-optional-refs-db-params
 ifdef GERRIT_PRIMARY2_INSTANCE_ID
 		$(eval PRIMARY2_SERVICE_OPTIONAL_PARAMS := $(PRIMARY2_SERVICE_OPTIONAL_PARAMS) ParameterKey=InstanceId,ParameterValue=$(GERRIT_PRIMARY2_INSTANCE_ID))
 endif
@@ -193,7 +195,7 @@
 		ParameterKey=GerritKeyPrefix,ParameterValue=$(GERRIT_KEY_PREFIX)\
 		ParameterKey=DockerImage,ParameterValue=aws-gerrit/gerrit:$(IMAGE_TAG) \
 		ParameterKey=PeerSubdomain,ParameterValue=$(PRIMARY1_SUBDOMAIN) \
-		ParameterKey=LBSubdomain,ParameterValue=$(LB_SUBDOMAIN) \
+		ParameterKey=PrimariesGerritSubdomain,ParameterValue=$(PRIMARIES_GERRIT_SUBDOMAIN) \
 		ParameterKey=ReindexAtSartup,ParameterValue=true \
 		ParameterKey=GerritRAM,ParameterValue=$(GERRIT_RAM) \
 		ParameterKey=GerritCPU,ParameterValue=$(GERRIT_CPU) \
@@ -207,7 +209,8 @@
 		$(LDAP_ACCOUNT_PATTERN_PARAM) \
 		$(METRICS_CW_OPTIONAL_PARAMS) \
 		$(SMTP_OPTIONAL_PARAMS) \
-		$(GERRIT_ULIMITS)
+		$(GERRIT_ULIMITS) \
+		$(REFS_DB_OPTIONAL_PARAMS)
 
 service-replication:
 	$(AWS_FC_COMMAND) create-stack \
@@ -269,33 +272,6 @@
 		$(GERRIT_OPTIONAL_PARAMS_REPLICA_AUTO_SCALING_CAPACITY) \
 		$(GERRIT_OPTIONAL_PARAMS_REPLICA_AUTO_SCALING_POLICY)
 
-service-lb:
-ifdef LOAD_BALANCER_SCHEME
-		$(eval SERVICE_OPTIONAL_PARAMS := $(SERVICE_OPTIONAL_PARAMS) ParameterKey=LoadBalancerScheme,ParameterValue=$(LOAD_BALANCER_SCHEME))
-endif
-ifdef HA_PROXY_DESIRED_COUNT
-		$(eval SERVICE_OPTIONAL_PARAMS := $(SERVICE_OPTIONAL_PARAMS) ParameterKey=DesiredCount,ParameterValue=$(HA_PROXY_DESIRED_COUNT))
-endif
-
-	$(AWS_FC_COMMAND) create-stack \
-		--stack-name $(LOAD_BALANCER_STACK_NAME) \
-		--capabilities CAPABILITY_IAM  \
-		--template-body file://`pwd`/$(LOAD_BALANCER_TEMPLATE) \
-		--region $(AWS_REGION) \
-		--parameters \
-		ParameterKey=ClusterStackName,ParameterValue=$(CLUSTER_STACK_NAME) \
-		ParameterKey=Primary1ServiceStackName,ParameterValue=$(SERVICE_PRIMARY1_STACK_NAME) \
-		ParameterKey=Primary2ServiceStackName,ParameterValue=$(SERVICE_PRIMARY2_STACK_NAME) \
-		ParameterKey=HostedZoneName,ParameterValue=$(HOSTED_ZONE_NAME) \
-		ParameterKey=DockerRegistryUrl,ParameterValue=$(DOCKER_REGISTRY_URI) \
-		ParameterKey=GerritKeyPrefix,ParameterValue=$(GERRIT_KEY_PREFIX)\
-		ParameterKey=CertificateArn,ParameterValue=$(SSL_CERTIFICATE_ARN) \
-		ParameterKey=Subdomain,ParameterValue=$(LB_SUBDOMAIN) \
-		ParameterKey=TemplateBucketName,ParameterValue=$(TEMPLATE_BUCKET_NAME) \
-		ParameterKey=HAProxyDockerImage,ParameterValue=aws-gerrit/haproxy:$(HAPROXY_HEAD_SHA1) \
-		ParameterKey=SidecarDockerImage,ParameterValue=aws-gerrit/syslog-sidecar:$(SYSLOG_HEAD_SHA1) \
-		$(SERVICE_OPTIONAL_PARAMS)
-
 dns-routing:
 	$(AWS_FC_COMMAND) create-stack \
 		--stack-name $(DNS_ROUTING_STACK_NAME) \
@@ -305,7 +281,6 @@
 		--parameters \
 		ParameterKey=Primary1ServiceStackName,ParameterValue=$(SERVICE_PRIMARY1_STACK_NAME) \
 		ParameterKey=Primary2ServiceStackName,ParameterValue=$(SERVICE_PRIMARY2_STACK_NAME) \
-		ParameterKey=LBServiceStackName,ParameterValue=$(LOAD_BALANCER_STACK_NAME) \
 		ParameterKey=ClusterStackName,ParameterValue=$(CLUSTER_STACK_NAME) \
 		ParameterKey=PrimariesGerritHostedZoneName,ParameterValue=$(HOSTED_ZONE_NAME) \
 		ParameterKey=PrimariesGerritSubdomain,ParameterValue=$(PRIMARIES_GERRIT_SUBDOMAIN)
@@ -372,13 +347,6 @@
 	--region $(AWS_REGION)
 	@echo "*** Service stack '$(SERVICE_REPLICA_STACK_NAME)' created"
 
-wait-for-service-lb-creation:
-	@echo "*** Wait for service lb stack '$(LOAD_BALANCER_STACK_NAME)' creation"
-	$(AWS_FC_COMMAND) wait stack-create-complete \
-	--stack-name $(LOAD_BALANCER_STACK_NAME) \
-	--region $(AWS_REGION)
-	@echo "*** Service stack '$(LOAD_BALANCER_STACK_NAME)' created"
-
 wait-for-dns-routing-creation:
 	@echo "*** Wait for DNS routing stack '$(DNS_ROUTING_STACK_NAME)' creation"
 	$(AWS_FC_COMMAND) wait stack-create-complete \
@@ -421,13 +389,6 @@
 	--region $(AWS_REGION)
 	@echo "*** Service stack replica '$(SERVICE_REPLICA_STACK_NAME)' deleted"
 
-wait-for-service-lb-deletion:
-	@echo "*** Wait for service lb stack '$(LOAD_BALANCER_STACK_NAME)' deletion"
-	$(AWS_FC_COMMAND) wait stack-delete-complete \
-	--stack-name $(LOAD_BALANCER_STACK_NAME) \
-	--region $(AWS_REGION)
-	@echo "*** Service stack '$(LOAD_BALANCER_STACK_NAME)' deleted"
-
 wait-for-dns-routing-deletion:
 	@echo "*** Wait for DNS routing stack '$(DNS_ROUTING_STACK_NAME)' deletion"
 	$(AWS_FC_COMMAND) wait stack-delete-complete \
@@ -469,11 +430,6 @@
 	--stack-name $(SERVICE_REPLICA_STACK_NAME) \
 	--region $(AWS_REGION)
 
-delete-service-lb:
-	$(AWS_FC_COMMAND) delete-stack \
-	--stack-name $(LOAD_BALANCER_STACK_NAME) \
-	--region $(AWS_REGION)
-
 delete-service-replication:
 	$(AWS_FC_COMMAND) delete-stack \
 	--stack-name $(SERVICE_REPLICATION_STACK_NAME) \
@@ -490,7 +446,6 @@
 	--region $(AWS_REGION)
 
 delete-all: delete-dns-routing wait-for-dns-routing-deletion \
-						delete-service-lb wait-for-service-lb-deletion \
 						delete-service-primary-1 delete-service-primary-2 delete-service-replica \
 						wait-for-service-primary-1-deletion wait-for-service-primary-2-deletion wait-for-service-replica-deletion \
 						$(optional_dashboard_targets_deletion) \
@@ -498,7 +453,7 @@
 						$(optional_git_gc_targets_deletion) \
 						delete-cluster wait-for-cluster-deletion
 
-delete-all-including-retained-stack: confirm-persistent-stack-deletion delete-all delete-git-primary-persistent-stack delete-git-replica-persistent-stack delete-network-persistent-stack
+delete-all-including-retained-stack: confirm-persistent-stack-deletion delete-all delete-git-primary-persistent-stack delete-git-replica-persistent-stack delete-network-persistent-stack delete-dynamodb-persistent-stack
 
 delete-git-primary-persistent-stack:
 
@@ -521,15 +476,9 @@
 ifeq ($(MULTISITE_ENABLED),true)
 	$(MAKE) -C ../gerrit gerrit-publish RECIPE=dual-primary PLUGINS="$(MULTI_SITE_PLUGINS)" PLUGINS_LIBS_LINKS="$(MULTI_SITE_PLUGINS_LIBS_LINKS)" MAVEN_LIBS="$(MULTI_SITE_MAVEN_LIBS)"
 else
-	$(MAKE) -C ../gerrit gerrit-publish RECIPE=dual-primary PLUGINS="$(SINGLE_SITE_PLUGINS)"
+	$(MAKE) -C ../gerrit gerrit-publish RECIPE=dual-primary PLUGINS="$(HA_SITE_PLUGINS)" PLUGINS_LIBS_LINKS="$(HA_SITE_PLUGINS_LIBS_LINKS)"
 endif
 
-haproxy-publish:
-	$(MAKE) -C haproxy haproxy-publish
-
-syslog-sidecar-publish:
-	$(MAKE) -C syslog-sidecar syslog-sidecar-publish
-
 git-daemon-publish:
 	$(MAKE) -C ../primary-replica/git-daemon git-daemon-publish
 
@@ -541,3 +490,28 @@
 ifdef AUTOREINDEX_POLL_INTERVAL
 		$(eval HA_OPTIONAL_PARAMS := ParameterKey=AutoReindexPollInterval,ParameterValue=$(AUTOREINDEX_POLL_INTERVAL))
 endif
+
+set-optional-refs-db-params:
+	$(eval REFS_DB_OPTIONAL_PARAMS=)
+ifdef DYNAMODB_LOCKS_TABLE_NAME
+		$(eval REFS_DB_OPTIONAL_PARAMS := $(REFS_DB_OPTIONAL_PARAMS) ParameterKey=DynamoDBLocksTableName,ParameterValue=$(DYNAMODB_LOCKS_TABLE_NAME))
+endif
+ifdef DYNAMODB_REFS_TABLE_NAME
+		$(eval REFS_DB_OPTIONAL_PARAMS := $(REFS_DB_OPTIONAL_PARAMS) ParameterKey=DynamoDBRefsTableName,ParameterValue=$(DYNAMODB_REFS_TABLE_NAME))
+endif
+
+delete-dynamodb-persistent-stack:
+	$(eval DYNAMODB_STACK_NAME=$(shell $(AWS_FC_COMMAND) list-stacks --stack-status-filter CREATE_COMPLETE --query "StackSummaries[*].StackName" | jq -r '.[]| select(startswith("$(CLUSTER_STACK_NAME)-DynamoDBPersistentStack"))'))
+
+	$(if $(DYNAMODB_STACK_NAME), \
+		$(AWS_FC_COMMAND) delete-stack \
+			--stack-name $(DYNAMODB_STACK_NAME) \
+			--region $(AWS_REGION) && \
+		echo "*** Wait for DynamoDB stack '$(DYNAMODB_STACK_NAME)' deletion" && \
+		$(AWS_FC_COMMAND) wait stack-delete-complete \
+			--stack-name $(DYNAMODB_STACK_NAME) \
+			--region $(AWS_REGION) && \
+		echo "*** DynamoDB stack '$(DYNAMODB_STACK_NAME)' deleted" \
+		, \
+		echo "No DynamoDB stack found. Nothing to do." \
+	)
\ No newline at end of file
diff --git a/dual-primary/README.md b/dual-primary/README.md
index f08f391..23bc084 100644
--- a/dual-primary/README.md
+++ b/dual-primary/README.md
@@ -10,7 +10,6 @@
 * `cf-service-primary`: define the service stack running the gerrit primary
 * `cf-dns-route`: define the DNS routing for the service
 * `cf-service-replica`: define the service stack running the gerrit replica
-* `cf-service-lb`: define the LBs in front of gerrit primaries (this includes haproxy as well as NLB)
 * `cf-dashboard`: define the CloudWatch dashboard for the services
 
 When the recipe enables the replication_service (see [docs](#replication-service))
@@ -98,6 +97,10 @@
 SUBNET2_CIDR=10.0.32.0/24
 ```
 
+Note that if the refs-db dynamodb tables were created as part of the initial
+stack (`CREATE_REFS_DB_TABLES` was set to `true`), you will need to explicitly
+set it to `false` to avoid attempting to create the same tables again.
+
 3. Deploy the *green* stack:
 
 ```bash
@@ -161,7 +164,6 @@
 * `PRIMARY1_SUBDOMAIN`: Optional. Name of the primary 1 sub domain. `gerrit-primary-1-demo` by default.
 * `PRIMARY2_SUBDOMAIN`: Optional. Name of the primary 2 sub domain. `gerrit-primary-2-demo` by default.
 * `REPLICA_SUBDOMAIN`: Mandatory. The subdomain of the Gerrit replica. For example: `<AWS_PREFIX>-replica`
-* `LB_SUBDOMAIN`: Mandatory. The subdomain of the Gerrit load balancer. For example: `<AWS_PREFIX>-dual-primary`
 * `PRIMARIES_GERRIT_SUBDOMAIN`: Mandatory. The subdomain of the lb serving traffic to both primary gerrit instances.
    For example: `<AWS_PREFIX>-primaries`
 * `PRIMARY_FILESYSTEM_THROUGHPUT_MODE`: Optional. The throughput mode for the primary file system to be created.
@@ -176,17 +178,6 @@
 * `GERRIT_PRIMARY2_INSTANCE_ID`: Optional. Identifier for the Gerrit primary2 instance.
 "gerrit-dual-primary-PRIMARY2" by default.
 
-* `HA_PROXY_DESIRED_COUNT`: Optional. Desired number of haproxy services.
-"2" by default. Minimum: "2".
-
-*Note* ha-proxies are running on ec2 instances with a ratio of 1 to 1: each
-ec2 node hosts one and only one ha-proxy. By increasing the number of desired
-ha-proxies then, the size of the autoscaling group hosting them also increases
-accordingly.
-
-* `HA_PROXY_MAX_COUNT`: Optional. Maximum number of EC2 instances in the haproxy autoscaling group.
-"2" by default. Minimum: "2".
-
 * `PRIMARY_MAX_COUNT`: Optional. Maximum number of EC2 instances in the primary autoscaling group.
 "2" by default. Minimum: "2".
 
@@ -211,6 +202,19 @@
 Default: `10m`
 high-availability docs [here](https://gerrit.googlesource.com/plugins/high-availability/+/refs/heads/master/src/main/resources/Documentation/config.md)
 
+* `DYNAMODB_LOCKS_TABLE_NAME`. Optional. The name of the dynamoDB table used to
+  store distribute locking.
+  Default: `locksTable`
+  See DynamoDB lock client [here](https://github.com/awslabs/amazon-dynamodb-lock-client)
+
+* `DYNAMODB_REFS_TABLE_NAME`. Optional. The name of the dynamoDB table used to
+  store git refs and their associated sha1.
+  Default: `refsDb`
+
+* `CREATE_REFS_DB_TABLES`. Optional. Whether to create the DynamoDB refs and
+  lock tables.
+  Default: `false`
+
 ##### Shared filesystem for replicas
 
 Similarly to primary nodes, replicas share a data via an EFS filesystem which is
@@ -356,7 +360,7 @@
 for more information on this.
 
 ##### Requirements
-* Kafka brokers and Zookeeper are required by this recipe and are expected to exist
+* Kafka brokers and DynamoDB are required by this recipe and are expected to exist
 and accessible with server-side TLS security enabled by the primary instances
 resulting from the deployment of this recipe.
 * Replication service must be enabled to allow syncing of Git data.
@@ -365,15 +369,9 @@
 
 * `MULTISITE_ENABLED`: Optional. Whether this Gerrit is part of a multi-site
 cluster deployment. "false" by default.
-* `MULTISITE_ZOOKEEPER_CONNECT_STRING`: Required when "MULTISITE_ENABLED=true".
-Connection string to Zookeeper.
 * `MULTISITE_KAFKA_BROKERS`: Required when "MULTISITE_ENABLED=true".
 Comma separated list of Kafka broker hosts (host:port)
 to use for publishing events to the message broker.
-* `MULTISITE_ZOOKEEPER_ROOT_NODE` Optional. Root node to use in Zookeeper to
-store/retrieve information.
-Constraint: a slash-separated ('/') string not starting with a slash ('/')
-"gerrit/multi-site" by default.
 * `MULTISITE_GLOBAL_PROJECTS`: Optional. Comma separated list of patterns (see [projects.pattern](https://gerrit.googlesource.com/plugins/multi-site/+/refs/heads/stable-3.2/src/main/resources/Documentation/config.md))
 to specify which projects are available across all sites. This parametes applies to both multi-site
 and replication service remote destinations.
@@ -433,10 +431,12 @@
 * EFS stack
 * VPC and subnets (if created as part of this deployment, rather than externally
 provided)
+* Refs-DB DynamoDB stack (if created as part of this deployment, rather than
+  externally provided))
 
 Note that you can completely delete the stack, including explicitly retained
-resources such as the EFS Git filesystem, VPC and subnets, by issuing the more
-aggressive command:
+resources such as the EFS Git filesystem, VPC and subnets and DynamoDB stack by
+issuing the more aggressive command:
 
 ```
 make [AWS_REGION=a-valid-aws-region] [AWS_PREFIX=some-cluster-prefix] delete-all-including-retained-stack
diff --git a/dual-primary/cf-cluster.yml b/dual-primary/cf-cluster.yml
index 3e0335d..440c6d7 100644
--- a/dual-primary/cf-cluster.yml
+++ b/dual-primary/cf-cluster.yml
@@ -77,16 +77,6 @@
     Description: Gerrit primary filesystem throughput, measured in MiB/s. Valid values are 1-1024.
     Type: Number
     Default: 256
-  HAProxyMaxCount:
-    Description: The maximum number of EC2 instances in the haproxy autoscaling group
-    Type: Number
-    Default: 2
-  HAProxyDesiredCount:
-    Description: The desired number of haproxy instances
-    ConstraintDescription: number of haproxy must be at least 2
-    Type: Number
-    MinValue: 2
-    Default: 2
   PrimaryMaxCount:
     Description: The maximum number of EC2 instances in the primary autoscaling group
     ConstraintDescription: number of primary instances in the primary autoscaling group. Must be at least 2
@@ -163,8 +153,22 @@
   PrimariesGerritCertificateArn:
     Description: SSL Certificates ARN for the load balancer serving requests to the primary gerrit instances
     Type: String
+  DynamoDBLocksTableName:
+    Description: The name of the DynamoDB locks table
+    Type: String
+    Default: 'locksTable'
+  DynamoDBRefsTableName:
+    Description: The name of the DynamoDB refs table
+    Type: String
+    Default: 'refsDb'
+  CreateRefsDBTables:
+    Description: Whether to create DynamoDB tables for refs-db
+    Type: String
+    Default: false
+    AllowedValues: [true, false]
 
 Conditions:
+  ShouldCreateDynamoDBTables: !Equals [!Ref CreateRefsDBTables, "true"]
   isProvisionedThroughput: !Equals [!Ref PrimaryFileSystemThroughputMode, "provisioned"]
   CreatePrimaryEFS: !Equals [!Ref PrimaryFileSystemID, ""]
   CreateReplicaEFS: !Equals [!Ref ReplicaFileSystemID, ""]
@@ -262,48 +266,6 @@
 
           /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ReplicaECSAutoScalingGroup --region ${AWS::Region}
 
-  HAProxyECSAutoScalingGroup:
-    Type: AWS::AutoScaling::AutoScalingGroup
-    Properties:
-      VPCZoneIdentifier:
-        - !If [NetworkStackNeeded, !GetAtt ECSTaskNetworkStack.Outputs.PublicSubnetOneRef, !Ref Subnet1IdProp]
-        - !If [NetworkStackNeeded, !GetAtt ECSTaskNetworkStack.Outputs.PublicSubnetTwoRef, !Ref Subnet2IdProp]
-      LaunchConfigurationName: !Ref 'HAProxyLaunchConfiguration'
-      MinSize: '2'
-      MaxSize: !Ref HAProxyMaxCount
-      DesiredCapacity: !Ref HAProxyDesiredCount
-    CreationPolicy:
-      ResourceSignal:
-        Timeout: PT15M
-    UpdatePolicy:
-      AutoScalingReplacingUpdate:
-        WillReplace: 'true'
-
-  HAProxyLaunchConfiguration:
-    Type: AWS::AutoScaling::LaunchConfiguration
-    Properties:
-      ImageId: !Ref 'ECSAMI'
-      SecurityGroups: [!Ref 'EcsHostSecurityGroup']
-      InstanceType: !Ref 'InstanceType'
-      IamInstanceProfile: !Ref 'EC2InstanceProfile'
-      KeyName: !Ref ECSKeyName
-      UserData:
-        Fn::Base64: !Sub |
-          #!/bin/bash -xe
-          echo ECS_CLUSTER=${AWS::StackName}-ECSCluster >> /etc/ecs/ecs.config
-          echo ECS_INSTANCE_ATTRIBUTES={\"target_group\":\"haproxy\"} >> /etc/ecs/ecs.config
-
-          # Make sure latest version of the helper scripts are installed as per recommendation:
-          # https://github.com/awsdocs/aws-cloudformation-user-guide/blob/master/doc_source/cfn-helper-scripts-reference.md#using-the-latest-version
-          yum install -y aws-cfn-bootstrap wget
-
-          # Install the CloudWatch Logs agent
-          wget https://s3.amazonaws.com/amazoncloudwatch-agent/centos/amd64/latest/amazon-cloudwatch-agent.rpm
-          rpm -U ./amazon-cloudwatch-agent.rpm
-          /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s
-
-          /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource HAProxyECSAutoScalingGroup --region ${AWS::Region}
-
   PrimariesGerritLoadBalancer:
     Type: AWS::ElasticLoadBalancingV2::LoadBalancer
     Properties:
@@ -459,6 +421,9 @@
               - 'ecr:GetDownloadUrlForLayer'
               - 'ec2:AttachVolume'
               - 'ec2:DescribeVolumes'
+              - "dynamodb:CreateTable"
+              - "dynamodb:DeleteTable"
+              - "dynamodb:ListTables"
             Resource: '*'
 
   PrimaryGitFileSystemPermanentStack:
@@ -513,6 +478,17 @@
         Subnet2CIDR: !Ref 'Subnet2CIDR'
         Subnet2AZProp: !Ref 'Subnet2AZProp'
 
+  DynamoDBPersistentStack:
+    Type: AWS::CloudFormation::Stack
+    DeletionPolicy: Retain
+    Condition: ShouldCreateDynamoDBTables
+    Properties:
+      TemplateURL: !Join [ '', ['https://', !Ref TemplateBucketName, '.s3.amazonaws.com/cf-dynamodb-stack.yml'] ]
+      TimeoutInMinutes: '25'
+      Parameters:
+        DynamoDBRefsTableName: !Ref DynamoDBRefsTableName
+        DynamoDBLocksTableName: !Ref DynamoDBLocksTableName
+
 Outputs:
   ClusterName:
     Description: The name of the ECS cluster
diff --git a/dual-primary/cf-dns-route.yml b/dual-primary/cf-dns-route.yml
index 1755fbd..156cbc5 100644
--- a/dual-primary/cf-dns-route.yml
+++ b/dual-primary/cf-dns-route.yml
@@ -13,10 +13,6 @@
       Description: Stack name of the ECS Primary Gerrit service
       Type: String
       Default: gerrit-service-primary-2
-  LBServiceStackName:
-      Description: Stack name of the ECS LB service
-      Type: String
-      Default: gerrit-service
   PrimariesGerritSubdomain:
     Description: The subdomain of the load balancer serving requests to primary gerrit instances
     Type: String
@@ -71,29 +67,6 @@
             Fn::ImportValue:
               !Join [':', [!Ref 'Primary2ServiceStackName', 'CanonicalHostedZoneID']]
           EvaluateTargetHealth: False
-  LBDnsRecord:
-      Type: AWS::Route53::RecordSet
-      Properties:
-        Name:
-          !Join
-            - '.'
-            - - Fn::ImportValue: !Join [':', [!Ref 'LBServiceStackName', 'Subdomain']]
-              - Fn::ImportValue: !Join [':', [!Ref 'LBServiceStackName', 'HostedZoneName']]
-        HostedZoneName:
-          !Join
-            - ''
-            - - Fn::ImportValue: !Join [':', [!Ref 'LBServiceStackName', 'HostedZoneName']]
-              - '.'
-        Comment: DNS name for Gerrit LB.
-        Type: A
-        AliasTarget:
-          DNSName:
-            Fn::ImportValue:
-              !Join [':', [!Ref 'LBServiceStackName', 'PublicLoadBalancerDNSName']]
-          HostedZoneId:
-            Fn::ImportValue:
-              !Join [':', [!Ref 'LBServiceStackName', 'CanonicalHostedZoneID']]
-          EvaluateTargetHealth: False
 
   PrimariesGerritDnsRecord:
     Type: AWS::Route53::RecordSet
diff --git a/dual-primary/cf-service-lb.yml b/dual-primary/cf-service-lb.yml
deleted file mode 100644
index 334f1ca..0000000
--- a/dual-primary/cf-service-lb.yml
+++ /dev/null
@@ -1,262 +0,0 @@
-AWSTemplateFormatVersion: '2010-09-09'
-Description: Deploy a service into an ECS cluster behind a public load balancer.
-Parameters:
-  LBServiceName:
-    Type: String
-    Default: gerrit-load-balancer
-  ClusterStackName:
-      Description: Stack name of the ECS cluster to deploy the services
-      Type: String
-      Default: gerrit-cluster
-  TemplateBucketName:
-    Description: S3 bucket containing cloudformation templates
-    Type: String
-  EnvironmentName:
-      Description: An environment name used to build the log stream names
-      Type: String
-      Default: test
-  HAProxyDockerImage:
-        Description: HAProxy Docker image
-        Type: String
-        Default: aws-gerrit/haproxy:latest
-  SidecarDockerImage:
-        Description: Syslog sidecar Docker image
-        Type: String
-        Default: aws-gerrit/syslog-sidecar:latest
-  DockerRegistryUrl:
-        Description: Docker registry URL
-        Type: String
-  DesiredCount:
-        Description: How many instances of this task should we run across our cluster?
-        Type: Number
-        MinValue: 2
-        Default: 2
-        ConstraintDescription: number of haproxy must be at least 2
-  HTTPGerritPort:
-        Description: Gerrit HTTP port
-        Type: Number
-        Default: 8080
-  SSHGerritPort:
-        Description: Gerrit SSH port
-        Type: Number
-        Default: 29418
-  HTTPContainerPort:
-        Description: Gerrit HTTP port
-        Type: Number
-        Default: 80
-  HTTPSHostPort:
-        Description: Gerrit HTTPS port
-        Type: Number
-        Default: 443
-  HTTPHostPort:
-        Description: HAProxy HTTP port
-        Type: Number
-        Default: 80
-  CertificateArn:
-        Description: SSL Certificates ARN
-        Type: String
-  HostedZoneName:
-        Description: The route53 HostedZoneName.
-        Type: String
-  Subdomain:
-        Description: The subdomain of the Gerrit cluster
-        Type: String
-        Default: gerrit-dual-primary
-  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]
-  GerritKeyPrefix:
-        Description: Gerrit credentials keys prefix
-        Type: String
-  Primary1ServiceStackName:
-      Description: Stack name of the ECS Primary Gerrit service
-      Type: String
-      Default: gerrit-service-primary-1
-  Primary2ServiceStackName:
-      Description: Stack name of the ECS Primary Gerrit service
-      Type: String
-      Default: gerrit-service-primary-2
-  SyslogSidecarServiceName:
-      Description: HAPRoxy Syslog Sidecar service name
-      Type: String
-      Default: gerrit-haproxy-sidecar
-  HealthCheckGracePeriodSeconds:
-      Description: HAProxy Healtcheck Grace Period
-      Type: Number
-      Default: 60
-
-Resources:
-    LBService:
-        Type: AWS::ECS::Service
-        DependsOn:
-          - HTTPListener
-          - SSHListener
-        Properties:
-            Cluster:
-              Fn::ImportValue:
-                  !Join [':', [!Ref 'ClusterStackName', 'ClusterName']]
-            DesiredCount: !Ref DesiredCount
-            TaskDefinition: !Ref TaskDefinition
-            HealthCheckGracePeriodSeconds: !Ref HealthCheckGracePeriodSeconds
-            LoadBalancers:
-                - ContainerName: !Ref LBServiceName
-                  ContainerPort: !Ref HTTPContainerPort
-                  TargetGroupArn: !Ref HTTPTargetGroup
-                - ContainerName: !Ref LBServiceName
-                  ContainerPort: !Ref SSHGerritPort
-                  TargetGroupArn: !Ref SSHTargetGroup
-
-    TaskDefinition:
-        Type: AWS::ECS::TaskDefinition
-        Properties:
-            Family: !Sub '${LBServiceName}TaskDefinition'
-            TaskRoleArn: !GetAtt ECSTaskExecutionRoleStack.Outputs.TaskExecutionRoleRef
-            ExecutionRoleArn: !GetAtt ECSTaskExecutionRoleStack.Outputs.TaskExecutionRoleRef
-            NetworkMode: bridge
-            PlacementConstraints:
-                - Expression: !Sub 'attribute:target_group == haproxy'
-                  Type: "memberOf"
-            ContainerDefinitions:
-                - Name: !Ref LBServiceName
-                  Essential: true
-                  Image: !Sub '${DockerRegistryUrl}/${HAProxyDockerImage}'
-                  Environment:
-                    - Name: GERRIT_PRIMARY_1_URL
-                      Value:
-                        Fn::ImportValue: !Join [':', [!Ref 'Primary1ServiceStackName', 'PublicLoadBalancerDNSName']]
-                    - Name: GERRIT_PRIMARY_2_URL
-                      Value:
-                        Fn::ImportValue: !Join [':', [!Ref 'Primary2ServiceStackName', 'PublicLoadBalancerDNSName']]
-                    - Name: SYSLOG_SIDECAR
-                      Value: !Ref SyslogSidecarServiceName
-                  Cpu: 1024
-                  Memory: 2048
-                  PortMappings:
-                    - ContainerPort: !Ref HTTPContainerPort
-                      HostPort: !Ref HTTPHostPort
-                      Protocol: tcp
-                    - ContainerPort: !Ref SSHGerritPort
-                      HostPort: !Ref SSHGerritPort
-                      Protocol: tcp
-                  Links:
-                    - !Ref SyslogSidecarServiceName
-                  LogConfiguration:
-                    LogDriver: awslogs
-                    Options:
-                        awslogs-group: !Ref ClusterStackName
-                        awslogs-region: !Ref AWS::Region
-                        awslogs-stream-prefix: !Ref EnvironmentName
-                - Name: !Ref SyslogSidecarServiceName
-                  Essential: true
-                  Image: !Sub '${DockerRegistryUrl}/${SidecarDockerImage}'
-                  Cpu: 256
-                  Memory: 512
-                  LogConfiguration:
-                    LogDriver: awslogs
-                    Options:
-                        awslogs-group: !Ref ClusterStackName
-                        awslogs-region: !Ref AWS::Region
-                        awslogs-stream-prefix: !Ref EnvironmentName
-
-    ECSTaskExecutionRoleStack:
-      Type: AWS::CloudFormation::Stack
-      Properties:
-        TemplateURL: !Join [ '', ['https://', !Ref TemplateBucketName, '.s3.amazonaws.com/cf-gerrit-task-execution-role.yml'] ]
-        TimeoutInMinutes: '5'
-
-    LoadBalancer:
-        Type: AWS::ElasticLoadBalancingV2::LoadBalancer
-        Properties:
-            Type: network
-            Scheme: !Ref 'LoadBalancerScheme'
-            LoadBalancerAttributes:
-              - Key: 'load_balancing.cross_zone.enabled'
-                Value: true
-            Subnets:
-              - Fn::ImportValue:
-                  !Join [':', [!Ref 'ClusterStackName', 'PublicSubnetOne']]
-              - Fn::ImportValue:
-                  !Join [':', [!Ref 'ClusterStackName', 'PublicSubnetTwo']]
-            Tags:
-                - Key: Name
-                  Value: !Join ['-', [!Ref 'EnvironmentName', !Ref 'LBServiceName', 'alb']]
-
-    HTTPTargetGroup:
-        Type: AWS::ElasticLoadBalancingV2::TargetGroup
-        DependsOn: LoadBalancer
-        Properties:
-            VpcId:
-              Fn::ImportValue:
-                  !Join [':', [!Ref 'ClusterStackName', 'VPCId']]
-            Port: !Ref HTTPHostPort
-            Protocol: TCP
-            Name: 'haproxy-http'
-
-    HTTPListener:
-        Type: AWS::ElasticLoadBalancingV2::Listener
-        DependsOn: LoadBalancer
-        Properties:
-            Certificates:
-              - CertificateArn: !Ref CertificateArn
-            DefaultActions:
-            - Type: forward
-              TargetGroupArn: !Ref HTTPTargetGroup
-            LoadBalancerArn: !Ref LoadBalancer
-            Port: !Ref HTTPSHostPort
-            Protocol: TLS
-
-    SSHTargetGroup:
-        Type: AWS::ElasticLoadBalancingV2::TargetGroup
-        DependsOn: LoadBalancer
-        Properties:
-            VpcId:
-              Fn::ImportValue:
-                  !Join [':', [!Ref 'ClusterStackName', 'VPCId']]
-            Port: !Ref SSHGerritPort
-            Protocol: TCP
-            Name: 'haproxy-ssh'
-
-    SSHListener:
-        Type: AWS::ElasticLoadBalancingV2::Listener
-        DependsOn: LoadBalancer
-        Properties:
-            DefaultActions:
-            - Type: forward
-              TargetGroupArn: !Ref SSHTargetGroup
-            LoadBalancerArn: !Ref LoadBalancer
-            Port: !Ref SSHGerritPort
-            Protocol: TCP
-
-Outputs:
-  PublicLoadBalancerDNSName:
-    Description: The DNS name of the external load balancer
-    Value: !GetAtt 'LoadBalancer.DNSName'
-    Export:
-      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'PublicLoadBalancerDNSName' ] ]
-  CanonicalHostedZoneID:
-    Description: Canonical Hosted Zone ID
-    Value: !GetAtt 'LoadBalancer.CanonicalHostedZoneID'
-    Export:
-      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'CanonicalHostedZoneID' ] ]
-  PublicLoadBalancerUrl:
-    Description: The url of the external load balancer
-    Value: !Join ['', ['https://', !GetAtt 'LoadBalancer.DNSName']]
-    Export:
-      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'PublicLoadBalancerUrl' ] ]
-  HostedZoneName:
-    Description: Route53 Hosted Zone name
-    Value: !Ref HostedZoneName
-    Export:
-      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'HostedZoneName' ] ]
-  Subdomain:
-    Description: Service DNS subdomain
-    Value: !Ref Subdomain
-    Export:
-      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'Subdomain' ] ]
-  CanonicalWebUrl:
-    Description: Canonical Web URL
-    Value: !Sub 'https://${Subdomain}.${HostedZoneName}'
-    Export:
-      Name: !Join [ ':', [ !Ref 'AWS::StackName', 'CanonicalWebUrl' ] ]
diff --git a/dual-primary/cf-service-primary.yml b/dual-primary/cf-service-primary.yml
index d08c07a..8c3384d 100644
--- a/dual-primary/cf-service-primary.yml
+++ b/dual-primary/cf-service-primary.yml
@@ -36,8 +36,8 @@
   ReplicaSubdomain:
         Description: The subdomain of the Gerrit replica
         Type: String
-  LBSubdomain:
-        Description: The subdomain of the Gerrit load balancer
+  PrimariesGerritSubdomain:
+        Description: The subdomain of the load balancer fronting both gerrit-1 and gerrit-2
         Type: String
   LoadBalancerScheme:
         Description: Load Balancer scheme, the nodes of an internet-facing load balancer have public IP addresses.
@@ -172,16 +172,14 @@
     Description: Comma separated list of Kafka broker hosts (host:port) to use for publishing events to the message broker
     Type: CommaDelimitedList
     Default: ''
-  MultiSiteZookeeperConnectString:
-    Description: Connection string to Zookeeper
+  DynamoDBLocksTableName:
+    Description: The name of the DynamoDB locks table
     Type: String
-    Default: ''
-  MultiSiteZookeeperRootNode:
-    Description: Root node to use in Zookeeper to store/retrieve information
+    Default: 'locksTable'
+  DynamoDBRefsTableName:
+    Description: The name of the DynamoDB refs table
     Type: String
-    ConstraintDescription: Choose a slash-separated ('/') string not starting with a slash ('/')
-    AllowedPattern: '^[^\/].*'
-    Default: 'gerrit/multi-site'
+    Default: 'refsDb'
   AutoReindexPollInterval:
     Description: Interval between reindexing of all changes, accounts and groups.
     Type: String
@@ -253,7 +251,7 @@
                   Image: !Sub '${DockerRegistryUrl}/${DockerImage}'
                   Environment:
                     - Name: CANONICAL_WEB_URL
-                      Value: !Sub 'https://${LBSubdomain}.${HostedZoneName}'
+                      Value: !Sub 'https://${PrimariesGerritSubdomain}.${HostedZoneName}'
                     - Name: HTTPD_LISTEN_URL
                       Value: !Sub
                         - 'proxy-https://*:${HTTPContainerPort}/'
@@ -334,10 +332,12 @@
                       Value: !Ref MultiSiteEnabled
                     - Name: MULTISITE_KAFKA_BROKERS
                       Value: !Join [',', !Ref MultiSiteKafkaBrokers]
-                    - Name: MULTISITE_ZOOKEEPER_CONNECT_STRING
-                      Value: !Ref MultiSiteZookeeperConnectString
-                    - Name: MULTISITE_ZOOKEEPER_ROOT_NODE
-                      Value: !Ref MultiSiteZookeeperRootNode
+                    - Name: REFS_DB_ENABLED
+                      Value: true
+                    - Name: DYNAMODB_LOCKS_TABLE_NAME
+                      Value: !Ref DynamoDBLocksTableName
+                    - Name: DYNAMODB_REFS_TABLE_NAME
+                      Value: !Ref DynamoDBRefsTableName
                   Ulimits:
                     - Name: nofile
                       HardLimit: !Ref FileDescriptorsHardLimit
diff --git a/dual-primary/haproxy/Dockerfile b/dual-primary/haproxy/Dockerfile
deleted file mode 100644
index d2191e8..0000000
--- a/dual-primary/haproxy/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM haproxy:1.7.14
-
-RUN apt-get update && \
-    apt-get -y install gettext-base netcat && \
-    mkdir /var/lib/haproxy && \
-    mkdir /var/run/haproxy && \
-    chown haproxy: /var/lib/haproxy /var/run/haproxy
-
-COPY haproxy.cfg.template /usr/local/etc/haproxy/
-
-COPY docker-entrypoint.sh /usr/local/bin/
diff --git a/dual-primary/haproxy/Makefile b/dual-primary/haproxy/Makefile
deleted file mode 100644
index 98d7370..0000000
--- a/dual-primary/haproxy/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-include ../../Makefile.common
-include ../setup.env
-
-IMAGE_NAME:=haproxy
-
-docker-registry-login:
-	aws ecr get-login-password --region $(AWS_REGION) \
-		| docker login --username AWS --password-stdin $(DOCKER_REGISTRY_URI)/aws-gerrit/$(IMAGE_NAME)
-
-haproxy-build:
-	docker build -t aws-gerrit/$(IMAGE_NAME):$(HAPROXY_HEAD_SHA1) .
-	docker tag aws-gerrit/$(IMAGE_NAME):$(HAPROXY_HEAD_SHA1) $(DOCKER_REGISTRY_URI)/aws-gerrit/$(IMAGE_NAME):$(HAPROXY_HEAD_SHA1)
-
-haproxy-publish: docker-registry-login haproxy-build
-	docker push $(DOCKER_REGISTRY_URI)/aws-gerrit/$(IMAGE_NAME):$(HAPROXY_HEAD_SHA1)
diff --git a/dual-primary/haproxy/docker-entrypoint.sh b/dual-primary/haproxy/docker-entrypoint.sh
deleted file mode 100755
index b379564..0000000
--- a/dual-primary/haproxy/docker-entrypoint.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-set -e
-
-# first arg is `-f` or `--some-option`
-if [ "${1#-}" != "$1" ]; then
-	set -- haproxy "$@"
-fi
-
-if [ "$1" = 'haproxy' ]; then
-	# if the user wants "haproxy", let's use "haproxy-systemd-wrapper" instead so we can have proper reloadability implemented by upstream
-	shift # "haproxy"
-	set -- "$(which haproxy-systemd-wrapper)" -p /run/haproxy.pid "$@"
-fi
-
-envsubst < /usr/local/etc/haproxy/haproxy.cfg.template > /usr/local/etc/haproxy/haproxy.cfg
-
-exec "$@"
diff --git a/dual-primary/haproxy/haproxy.cfg.template b/dual-primary/haproxy/haproxy.cfg.template
deleted file mode 100644
index 7b4c714..0000000
--- a/dual-primary/haproxy/haproxy.cfg.template
+++ /dev/null
@@ -1,76 +0,0 @@
-global
-    log gerrit-haproxy-sidecar local0 debug
-
-    chroot /var/lib/haproxy
-    stats socket /var/run/haproxy/admin.sock mode 660 level admin
-    stats timeout 30s
-    user haproxy
-    group haproxy
-    daemon
-
-defaults
-    log     global
-    mode    http
-    option  httplog
-    option  dontlognull
-    timeout connect 5000
-    timeout client  900000
-    timeout server  900000
-    timeout check 30000
-
-frontend localnodes
-    bind *:80
-    mode http
-    option httplog
-    capture request header X-Forwarded-For len 15
-    log-format %[capture.req.hdr(0)]:%cp\ [%t]\ %f\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ {%hrl}\ {%hsl}\ %{+Q}r
-
-    default_backend primary
-
-frontend gitssh
-    bind *:29418
-    mode tcp
-    timeout client  5m
-
-    default_backend ssh
-
-backend primary
-    mode http
-    balance roundrobin
-    option forwardfor
-    default-server inter 10s fall 3 rise 2
-    option httpchk GET /config/server/healthcheck~status HTTP/1.0\r\nHost:\ $GERRIT_PRIMARY_1_URL
-    http-check expect status 200
-    server gerrit-1 $GERRIT_PRIMARY_1_URL:8080 check inter 10s
-    server gerrit-2 $GERRIT_PRIMARY_2_URL:8080 check inter 10s backup
-
-backend gerrit-1
-    mode http
-    option forwardfor
-    server gerrit-1 $GERRIT_PRIMARY_1_URL:8080
-
-backend gerrit-2
-    mode http
-    option forwardfor
-    server gerrit-2 $GERRIT_PRIMARY_2_URL:8080
-
-backend ssh
-    mode tcp
-    option redispatch
-    option httpchk GET /config/server/healthcheck~status HTTP/1.0\r\nHost:\ $GERRIT_PRIMARY_1_URL
-    http-check expect status 200
-    balance source
-    timeout connect 10s
-    timeout server 5m
-    server gerrit-ssh-1 $GERRIT_PRIMARY_1_URL:29418 check port 8080 inter 10s
-    server gerrit-ssh-2 $GERRIT_PRIMARY_2_URL:29418 check port 8080 inter 10s backup
-
-backend gerrit-ssh-1
-    mode http
-    option forwardfor
-    server gerrit-ssh-1 $GERRIT_PRIMARY_1_URL:29418
-
-backend gerrit-ssh-2
-    mode http
-    option forwardfor
-    server gerrit-ssh-2 $GERRIT_PRIMARY_2_URL:29418
diff --git a/dual-primary/setup.env.template b/dual-primary/setup.env.template
index c282ff6..8f76af9 100644
--- a/dual-primary/setup.env.template
+++ b/dual-primary/setup.env.template
@@ -1,7 +1,5 @@
 MULTISITE_ENABLED:=false
-MULTISITE_ZOOKEEPER_CONNECT_STRING:=zookeeper-yourcompany.com:2181
 MULTISITE_KAFKA_BROKERS:=kafka0-yourcompany.com:9092,kafka1-yourcompany.com:9092
-MULTISITE_ZOOKEEPER_ROOT_NODE:=gerrit/multi-site
 
 CLUSTER_INSTANCE_TYPE:=m4.2xlarge
 SERVICE_PRIMARY1_STACK_NAME:=$(AWS_PREFIX)-service-primary-1
@@ -21,7 +19,6 @@
 PRIMARY1_SUBDOMAIN:=$(AWS_PREFIX)-primary-1.gerrit-demo
 PRIMARY2_SUBDOMAIN:=$(AWS_PREFIX)-primary-2.gerrit-demo
 REPLICA_SUBDOMAIN:=$(AWS_PREFIX)-replica.gerrit-demo
-LB_SUBDOMAIN=$(AWS_PREFIX)-lb.gerrit-demo
 PRIMARIES_GERRIT_SUBDOMAIN=$(AWS_PREFIX)-primaries.gerrit-demo
 DOCKER_REGISTRY_URI:=<yourAccountId>.dkr.ecr.us-east-1.amazonaws.com
 SSL_CERTIFICATE_ARN=arn:aws:acm:us-east-1:<yourAccountId>:certificate/33e2c235-a4d1-42b7-b866-18d8d744975c
@@ -97,4 +94,8 @@
 # Existing SUBNET2 settings
 SUBNET2_CIDR=
 SUBNET2_ID=
-SUBNET2_AZ=
\ No newline at end of file
+SUBNET2_AZ=
+
+DYNAMODB_LOCKS_TABLE_NAME=$(AWS_PREFIX)-locksTable
+DYNAMODB_REFS_TABLE_NAME=$(AWS_PREFIX)-refsDb
+CREATE_REFS_DB_TABLES=false
\ No newline at end of file
diff --git a/dual-primary/syslog-sidecar/Dockerfile b/dual-primary/syslog-sidecar/Dockerfile
deleted file mode 100644
index 11f3059..0000000
--- a/dual-primary/syslog-sidecar/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM alpine:3.4
-MAINTAINER Ryan Schlesinger <ryan@outstand.com>
-
-RUN apk add --no-cache bash syslog-ng
-
-RUN mkdir /sidecar
-COPY config/* /etc/syslog-ng/
-COPY docker-entrypoint.sh /docker-entrypoint.sh
-VOLUME ["/sidecar"]
-CMD ["syslog-ng", "-F"]
-ENTRYPOINT ["/docker-entrypoint.sh"]
diff --git a/dual-primary/syslog-sidecar/Makefile b/dual-primary/syslog-sidecar/Makefile
deleted file mode 100644
index b2e5e97..0000000
--- a/dual-primary/syslog-sidecar/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-include ../../Makefile.common
-include ../setup.env
-
-IMAGE_NAME:=syslog-sidecar
-
-docker-registry-login:
-	aws ecr get-login-password --region $(AWS_REGION) \
-		| docker login --username AWS --password-stdin $(DOCKER_REGISTRY_URI)/aws-gerrit/$(IMAGE_NAME)
-
-syslog-sidecar-build:
-	docker build -t aws-gerrit/$(IMAGE_NAME):$(SYSLOG_HEAD_SHA1) .
-	docker tag aws-gerrit/$(IMAGE_NAME):$(SYSLOG_HEAD_SHA1) $(DOCKER_REGISTRY_URI)/aws-gerrit/$(IMAGE_NAME):$(SYSLOG_HEAD_SHA1)
-
-syslog-sidecar-publish: docker-registry-login syslog-sidecar-build
-	docker push $(DOCKER_REGISTRY_URI)/aws-gerrit/$(IMAGE_NAME):$(SYSLOG_HEAD_SHA1)
diff --git a/dual-primary/syslog-sidecar/config/syslog-ng-destination.out b/dual-primary/syslog-sidecar/config/syslog-ng-destination.out
deleted file mode 100644
index 170f7e4..0000000
--- a/dual-primary/syslog-sidecar/config/syslog-ng-destination.out
+++ /dev/null
@@ -1 +0,0 @@
-  destination d_stdout { pipe("/dev/stdout"); };
diff --git a/dual-primary/syslog-sidecar/config/syslog-ng-log.out b/dual-primary/syslog-sidecar/config/syslog-ng-log.out
deleted file mode 100644
index 6901c41..0000000
--- a/dual-primary/syslog-sidecar/config/syslog-ng-log.out
+++ /dev/null
@@ -1 +0,0 @@
-log { source(s_all); destination(d_stdout); };
diff --git a/dual-primary/syslog-sidecar/config/syslog-ng-plugins.std b/dual-primary/syslog-sidecar/config/syslog-ng-plugins.std
deleted file mode 100644
index ef0ce3e..0000000
--- a/dual-primary/syslog-sidecar/config/syslog-ng-plugins.std
+++ /dev/null
@@ -1 +0,0 @@
-@version: 3.7
diff --git a/dual-primary/syslog-sidecar/config/syslog-ng-source.sidecar b/dual-primary/syslog-sidecar/config/syslog-ng-source.sidecar
deleted file mode 100644
index 1181f78..0000000
--- a/dual-primary/syslog-sidecar/config/syslog-ng-source.sidecar
+++ /dev/null
@@ -1,5 +0,0 @@
-# sidecar log source for mounting between docker containers
-  network(
-    transport("udp")
-    port("514")
-  );
diff --git a/dual-primary/syslog-sidecar/config/syslog-ng-source.std b/dual-primary/syslog-sidecar/config/syslog-ng-source.std
deleted file mode 100644
index 5a50916..0000000
--- a/dual-primary/syslog-sidecar/config/syslog-ng-source.std
+++ /dev/null
@@ -1,8 +0,0 @@
-# ---------------------------------------------------------------------------------
-# Default syslog-ng sources; Do not edit this file!
-# append source with line on a file: syslog-ng-source.<package>
-# ---------------------------------------------------------------------------------
-# message generated by Syslog-NG
-  internal();
-# standard Linux log source (this is the default place for the syslog() function to send logs to)
-  unix-dgram("/dev/log");
diff --git a/dual-primary/syslog-sidecar/docker-entrypoint.sh b/dual-primary/syslog-sidecar/docker-entrypoint.sh
deleted file mode 100755
index be51a09..0000000
--- a/dual-primary/syslog-sidecar/docker-entrypoint.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-
-# The following two methods are ripped from alpine's syslog-ng package.
-# This allows us (and a user) to customize the config with snippets.
-grep_syslog_conf_entries() {
-  local section="$1" FN filelist
-  grep -v '^#' /etc/syslog-ng/syslog-ng-${section}.std
-  filelist=$(find /etc/syslog-ng/ -maxdepth 1 -type f -name "syslog-ng-${section}.*" | grep -Ev ".backup|.std|~")
-  if [ $? -eq 0 ]
-  then
-    for FN in ${filelist}
-    do
-      grep -v '^#' $FN
-    done
-  fi
-}
-
-update() {
-  local fname='/etc/syslog-ng/syslog-ng.conf'
-  local f_tmp="/etc/syslog-ng/syslog-ng.conf.$$"
-  for ng_std in options source destination filter log
-  do
-    [ -f /etc/syslog-ng/syslog-ng-${ng_std}.std ] || exit 1
-  done
-  {
-    # create options entries
-    grep_syslog_conf_entries plugins
-    echo "options {"
-    grep_syslog_conf_entries options
-    echo "};"
-    # create source entries
-    echo "source s_all {"
-    grep_syslog_conf_entries source
-    echo "};"
-    # create destination entries
-    grep_syslog_conf_entries destination
-    # create filter entries
-    grep_syslog_conf_entries filter
-    # create log entries
-    grep_syslog_conf_entries log
-  } > $f_tmp
-  cp -p $f_tmp $fname
-  rm -f $f_tmp
-}
-
-update
-
-echo Starting "$@"
-exec "$@"
diff --git a/gerrit/entrypoint.sh b/gerrit/entrypoint.sh
index a5e1128..4aa5446 100755
--- a/gerrit/entrypoint.sh
+++ b/gerrit/entrypoint.sh
@@ -10,8 +10,8 @@
 
   echo "Ensure primary specific plugins and libraries are not installed:"
   for jar in "lib/multi-site.jar" "plugins/multi-site.jar" "lib/replication.jar" \
-    "lib/events-broker.jar" "plugins/kafka-events.jar" "plugins/zookeeper-refdb.jar" \
-    "plugins/websession-broker.jar" "plugins/high-availability.jar"
+    "lib/events-broker.jar" "plugins/kafka-events.jar" "plugins/aws-dynamodb-refdb.jar" \
+    "plugins/websession-broker.jar" "plugins/high-availability.jar" "lib/high-availability.jar"
   do
     echo "rm -f /var/gerrit/$jar"
     rm -f /var/gerrit/"$jar"
diff --git a/gerrit/etc/gerrit.config.template b/gerrit/etc/gerrit.config.template
index 0cccdc9..7488c31 100644
--- a/gerrit/etc/gerrit.config.template
+++ b/gerrit/etc/gerrit.config.template
@@ -8,6 +8,9 @@
 	installDbModule = com.googlesource.gerrit.plugins.multisite.GitModule
 	installModule = com.googlesource.gerrit.plugins.multisite.Module
 	installModule = com.gerritforge.gerrit.eventbroker.BrokerApiModule
+{% elif REFS_DB_ENABLED is defined and REFS_DB_ENABLED == "true" %}
+    installDbModule = com.ericsson.gerrit.plugins.highavailability.ValidationModule
+    installModule = com.gerritforge.gerrit.globalrefdb.validation.LibModule
 {% endif %}
 [core]
 	packedGitLimit = {{ JGIT_CACHE_SIZE }}
@@ -104,3 +107,9 @@
     maxRequestSize = 10485760
     securityProtocol = SSL
 {% endif %}
+
+{% if (MULTISITE_ENABLED is defined and MULTISITE_ENABLED == "true") or (REFS_DB_ENABLED is defined and REFS_DB_ENABLED == "true") %}
+[plugin "aws-dynamodb-refdb"]
+    locksTableName = {{ DYNAMODB_LOCKS_TABLE_NAME }}
+    refsDbTableName = {{ DYNAMODB_REFS_TABLE_NAME }}
+{% endif %}
\ No newline at end of file
diff --git a/gerrit/etc/high-availability.config.template b/gerrit/etc/high-availability.config.template
index db00a79..8a3b635 100644
--- a/gerrit/etc/high-availability.config.template
+++ b/gerrit/etc/high-availability.config.template
@@ -14,5 +14,7 @@
 {% if MULTISITE_ENABLED is defined and MULTISITE_ENABLED == "true" %}
 [websession]
   synchronize = false
-{% endif %}
-
+{% elif REFS_DB_ENABLED is defined and REFS_DB_ENABLED == "true" %}
+[ref-database]
+  enabled = true
+{% endif %}
\ No newline at end of file
diff --git a/gerrit/etc/zookeeper-refdb.config.template b/gerrit/etc/zookeeper-refdb.config.template
deleted file mode 100644
index 7e0b649..0000000
--- a/gerrit/etc/zookeeper-refdb.config.template
+++ /dev/null
@@ -1,4 +0,0 @@
-[ref-database "zookeeper"]
-  connectString = {{ MULTISITE_ZOOKEEPER_CONNECT_STRING }}
-  sslConnection = true
-  rootNode = {{ MULTISITE_ZOOKEEPER_ROOT_NODE }}
\ No newline at end of file
diff --git a/gerrit/setup_gerrit.py b/gerrit/setup_gerrit.py
index 5af5795..74ecdba 100755
--- a/gerrit/setup_gerrit.py
+++ b/gerrit/setup_gerrit.py
@@ -169,7 +169,10 @@
         'METRICS_CLOUDWATCH_DRY_RUN': os.getenv('METRICS_CLOUDWATCH_DRY_RUN'),
         'METRICS_CLOUDWATCH_EXCLUDE_METRICS_LIST': os.getenv('METRICS_CLOUDWATCH_EXCLUDE_METRICS_LIST'),
         'MULTISITE_ENABLED': os.getenv('MULTISITE_ENABLED'),
-        'MULTISITE_KAFKA_BROKERS': os.getenv('MULTISITE_KAFKA_BROKERS')
+        'MULTISITE_KAFKA_BROKERS': os.getenv('MULTISITE_KAFKA_BROKERS'),
+        'REFS_DB_ENABLED': os.getenv('REFS_DB_ENABLED'),
+        'DYNAMODB_LOCKS_TABLE_NAME': os.getenv('DYNAMODB_LOCKS_TABLE_NAME'),
+        'DYNAMODB_REFS_TABLE_NAME': os.getenv('DYNAMODB_REFS_TABLE_NAME'),
     })
     f.write(template.render(config_for_template))
 
@@ -214,22 +217,11 @@
         f.write(template.render(
             HA_PEER_URL=os.getenv('HA_PEER_URL'),
             HA_AUTOREINDEX_POLL_INTERVAL=os.getenv('HA_AUTOREINDEX_POLL_INTERVAL'),
-            MULTISITE_ENABLED=os.getenv('MULTISITE_ENABLED')
+            MULTISITE_ENABLED=os.getenv('MULTISITE_ENABLED'),
+            REFS_DB_ENABLED=os.getenv('REFS_DB_ENABLED')
         ))
 
 if setupMultiSite:
-    CONFIGURATION_FILE = "zookeeper-refdb.config"
-    CONFIGURATION_TARGET = GERRIT_CONFIG_DIRECTORY + CONFIGURATION_FILE
-    TEMPLATE_FILE = CONFIGURATION_FILE + ".template"
-
-    print("*** "+ CONFIGURATION_TARGET)
-    template = env.get_template("zookeeper-refdb.config.template")
-    with open(CONFIGURATION_TARGET, 'w', encoding='utf-8') as f:
-        f.write(template.render(
-            MULTISITE_ZOOKEEPER_CONNECT_STRING=os.getenv('MULTISITE_ZOOKEEPER_CONNECT_STRING'),
-            MULTISITE_ZOOKEEPER_ROOT_NODE=os.getenv('MULTISITE_ZOOKEEPER_ROOT_NODE')
-        ))
-
     CONFIGURATION_TARGET = GERRIT_CONFIG_DIRECTORY + "multi-site.config"
 
     print("*** "+ CONFIGURATION_TARGET)
diff --git a/primary-replica/cf-service-primary.yml b/primary-replica/cf-service-primary.yml
index 7c10836..aed8067 100644
--- a/primary-replica/cf-service-primary.yml
+++ b/primary-replica/cf-service-primary.yml
@@ -22,10 +22,6 @@
         Description: Gerrit official Docker image
         Type: String
         Default: aws-gerrit/gerrit:latest
-  GerritLBDockerImage:
-        Description: Load Balancer official Docker image
-        Type: String
-        Default: haproxy:1.7
   DockerRegistryUrl:
         Description: Docker registry URL
         Type: String