Skip to content

Commit e648c92

Browse files
Merge pull request #23 from zerodha/set-region-clients
feat: allow users to set region for nomad clients
2 parents f459f73 + 6793bf4 commit e648c92

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

modules/nomad-clients/locals.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
locals {
22
setup_client = templatefile("${path.module}/scripts/setup_client.tftpl.sh", {
3+
aws_region = var.aws_region
34
route_53_resolver_address = var.route_53_resolver_address
45
enable_docker_plugin = var.enable_docker_plugin
56
nomad_join_tag_key = "nomad_ec2_join"
@@ -11,4 +12,4 @@ locals {
1112
nomad_acl_enable = var.nomad_acl_enable
1213
})
1314
})
14-
}
15+
}

modules/nomad-clients/scripts/setup_client.tftpl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ set_hostname() {
8383
prepare_dns_config() {
8484
cat <<EOF >/etc/nomad.d/route53_resolv.conf
8585
nameserver ${route_53_resolver_address}
86-
search ap-south-1.compute.internal
86+
search ${aws_region}.compute.internal
8787
EOF
8888
}
8989

@@ -130,7 +130,7 @@ EOF
130130
client {
131131
enabled = true
132132
server_join {
133-
retry_join = ["provider=aws region=ap-south-1 tag_key=${nomad_join_tag_key} tag_value=${nomad_join_tag_value}"]
133+
retry_join = ["provider=aws region=${aws_region} tag_key=${nomad_join_tag_key} tag_value=${nomad_join_tag_value}"]
134134
}
135135
meta {
136136
$(for tag in "$${AWS_TAGS[@]}"; do

modules/nomad-clients/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ variable "ami" {
66
nullable = false
77
}
88

9+
variable "aws_region" {
10+
description = "AWS region to deploy the cluster in"
11+
type = string
12+
default = "ap-south-1"
13+
nullable = false
14+
}
15+
916
variable "client_name" {
1017
description = "Name of the Auto Scaling Group (ASG) nodes deployed as Nomad clients"
1118
type = string

0 commit comments

Comments
 (0)