Allow cluster to be created in regions other than us-east-1

S3 bucket creation for regions other than us-east-1 needs additional
LocationConstraint configuration. However this must not be set when the
region is us-east-1.

Details can be found here[1]

[1] https://github.com/aws/aws-cli/issues/2603

Bug: Issue 13095
Change-Id: I3d4fc5a6e8ec536001aec22c8d0e36c17523bb87
diff --git a/Makefile.common b/Makefile.common
index e5bf82a..13d567f 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -7,5 +7,11 @@
 		aws ec2 create-key-pair --region $(AWS_REGION) --key-name $(CLUSTER_KEYS) --query 'KeyMaterial' --output text > $(CLUSTER_KEYS).pem
 
 upload-common-templates:
-	export AWS_PAGER=; aws s3api head-bucket --bucket $(TEMPLATE_BUCKET_NAME) 2>/dev/null || aws s3api create-bucket --bucket $(TEMPLATE_BUCKET_NAME)
+	$(eval CREATE_BUCKET_PARAMS := --bucket $(TEMPLATE_BUCKET_NAME))
+ifneq ("$(AWS_REGION)", "us-east-1")
+		$(eval CREATE_BUCKET_PARAMS := $(CREATE_BUCKET_PARAMS) --create-bucket-configuration LocationConstraint=$(AWS_REGION))
+endif
+
+	export AWS_PAGER=; aws s3api head-bucket --bucket $(TEMPLATE_BUCKET_NAME) 2>/dev/null || \
+		aws s3api create-bucket $(CREATE_BUCKET_PARAMS)
 	aws s3 cp ../common-templates/cf-gerrit-task-execution-role.yml s3://$(TEMPLATE_BUCKET_NAME)/