Skip to content

Commit 40c481e

Browse files
committed
Attach EIP to server instance to handle nomad and consul provider configuration gracefully
1 parent bf387fd commit 40c481e

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

aws-ec2-control_plane.tf

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,15 @@ resource "aws_instance" "server" {
7070
http_endpoint = "enabled"
7171
instance_metadata_tags = "enabled"
7272
}
73-
}
73+
74+
lifecycle {
75+
create_before_destroy = true
76+
}
77+
}
78+
79+
80+
resource "aws_eip" "nomad_consul" {
81+
domain = "vpc"
82+
instance = aws_instance.server[0].id
83+
}
84+

aws-ec2-data_plane.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ resource "aws_instance" "public_client" {
6262
http_endpoint = "enabled"
6363
instance_metadata_tags = "enabled"
6464
}
65+
66+
lifecycle {
67+
create_before_destroy = true
68+
}
6569
}

terraform.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ provider "aws" {
3030

3131
provider "consul" {
3232
datacenter = var.datacenter
33-
address = "${aws_instance.server[0].public_ip}:8443"
33+
#address = "${aws_instance.server[0].public_ip}:8443"
34+
address = "${aws_eip.nomad_consul.public_ip}:8443"
3435
token = random_uuid.consul_mgmt_token.result
3536
ca_pem = tls_self_signed_cert.datacenter_ca.cert_pem
3637
scheme = "https"
3738
insecure_https = true
3839
}
3940

4041
provider "nomad" {
41-
address = "https://${aws_instance.server[0].public_ip}:4646"
42+
#address = "https://${aws_instance.server[0].public_ip}:4646"
43+
address = "https://${aws_eip.nomad_consul.public_ip}:4646"
4244
region = var.domain
4345
secret_id = random_uuid.nomad_mgmt_token.result
4446
ca_pem = tls_self_signed_cert.datacenter_ca.cert_pem

0 commit comments

Comments
 (0)