Skip to content

Commit f831ade

Browse files
author
Joshua Timmons
authored
Fix Ingress Gateway Consul registration (#65)
* Fix nomad service protocol registation * Use nat_public_ips for ECS cluster * Remove http proxy configs * Move retries to group level
1 parent 59cbd51 commit f831ade

File tree

29 files changed

+204
-140
lines changed

29 files changed

+204
-140
lines changed

examples/hcp-ec2-demo/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ resource "hcp_hvn" "main" {
2626

2727
module "aws_hcp_consul" {
2828
source = "hashicorp/hcp-consul/aws"
29-
version = "~> 0.8.7"
29+
version = "~> 0.8.8"
3030

3131
hvn = hcp_hvn.main
3232
vpc_id = module.vpc.vpc_id
@@ -54,7 +54,7 @@ resource "aws_key_pair" "hcp_ec2" {
5454
count = var.ssh ? 1 : 0
5555

5656
public_key = tls_private_key.ssh.public_key_openssh
57-
key_name = "hcp-ec2-key"
57+
key_name = "hcp-ec2-key-${var.cluster_id}"
5858
}
5959

6060
resource "local_file" "ssh_key" {
@@ -67,14 +67,14 @@ resource "local_file" "ssh_key" {
6767

6868
module "aws_ec2_consul_client" {
6969
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
70-
version = "~> 0.8.7"
70+
version = "~> 0.8.8"
7171

7272
allowed_http_cidr_blocks = ["0.0.0.0/0"]
7373
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
7474
client_ca_file = hcp_consul_cluster.main.consul_ca_file
7575
client_config_file = hcp_consul_cluster.main.consul_config_file
7676
consul_version = hcp_consul_cluster.main.consul_version
77-
igw_id = module.vpc.igw_id
77+
nat_public_ips = module.vpc.nat_public_ips
7878
install_demo_app = var.install_demo_app
7979
root_token = hcp_consul_cluster_root_token.token.secret_id
8080
security_group_id = module.aws_hcp_consul.security_group_id

examples/hcp-ecs-demo/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ resource "hcp_hvn" "main" {
2828

2929
module "aws_hcp_consul" {
3030
source = "hashicorp/hcp-consul/aws"
31-
version = "~> 0.8.7"
31+
version = "~> 0.8.8"
3232

3333
hvn = hcp_hvn.main
3434
vpc_id = module.vpc.vpc_id
@@ -49,7 +49,7 @@ resource "hcp_consul_cluster_root_token" "token" {
4949

5050
module "aws_ecs_cluster" {
5151
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
52-
version = "~> 0.8.7"
52+
version = "~> 0.8.8"
5353

5454
allowed_http_cidr_blocks = ["0.0.0.0/0"]
5555
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
@@ -60,7 +60,7 @@ module "aws_ecs_cluster" {
6060
consul_url = hcp_consul_cluster.main.consul_private_endpoint_url
6161
consul_version = substr(hcp_consul_cluster.main.consul_version, 1, -1)
6262
datacenter = hcp_consul_cluster.main.datacenter
63-
igw_id = module.vpc.igw_id
63+
nat_public_ips = module.vpc.nat_public_ips
6464
private_subnet_ids = module.vpc.private_subnets
6565
public_subnet_ids = module.vpc.public_subnets
6666
region = var.vpc_region

examples/hcp-eks-demo/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ resource "hcp_hvn" "main" {
6363

6464
module "aws_hcp_consul" {
6565
source = "hashicorp/hcp-consul/aws"
66-
version = "~> 0.8.7"
66+
version = "~> 0.8.8"
6767

6868
hvn = hcp_hvn.main
6969
vpc_id = module.vpc.vpc_id
@@ -85,7 +85,7 @@ resource "hcp_consul_cluster_root_token" "token" {
8585

8686
module "eks_consul_client" {
8787
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
88-
version = "~> 0.8.7"
88+
version = "~> 0.8.8"
8989

9090
boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
9191
cluster_id = hcp_consul_cluster.main.cluster_id
@@ -105,7 +105,7 @@ module "eks_consul_client" {
105105
module "demo_app" {
106106
count = var.install_demo_app ? 1 : 0
107107
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
108-
version = "~> 0.8.7"
108+
version = "~> 0.8.8"
109109

110110
depends_on = [module.eks_consul_client]
111111
}

hcp-ui-templates/ec2-existing-vpc/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ resource "hcp_hvn" "main" {
4545

4646
module "aws_hcp_consul" {
4747
source = "hashicorp/hcp-consul/aws"
48-
version = "~> 0.8.7"
48+
version = "~> 0.8.8"
4949

5050
hvn = hcp_hvn.main
5151
vpc_id = local.vpc_id
@@ -73,7 +73,7 @@ resource "aws_key_pair" "hcp_ec2" {
7373
count = local.ssh ? 1 : 0
7474

7575
public_key = tls_private_key.ssh.public_key_openssh
76-
key_name = "hcp-ec2-key"
76+
key_name = "hcp-ec2-key-${local.cluster_id}"
7777
}
7878

7979
resource "local_file" "ssh_key" {
@@ -86,14 +86,14 @@ resource "local_file" "ssh_key" {
8686

8787
module "aws_ec2_consul_client" {
8888
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
89-
version = "~> 0.8.7"
89+
version = "~> 0.8.8"
9090

9191
allowed_http_cidr_blocks = ["0.0.0.0/0"]
9292
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
9393
client_ca_file = hcp_consul_cluster.main.consul_ca_file
9494
client_config_file = hcp_consul_cluster.main.consul_config_file
9595
consul_version = hcp_consul_cluster.main.consul_version
96-
igw_id = module.vpc.igw_id
96+
nat_public_ips = module.vpc.nat_public_ips
9797
install_demo_app = local.install_demo_app
9898
root_token = hcp_consul_cluster_root_token.token.secret_id
9999
security_group_id = module.aws_hcp_consul.security_group_id

hcp-ui-templates/ec2/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ resource "hcp_hvn" "main" {
6060

6161
module "aws_hcp_consul" {
6262
source = "hashicorp/hcp-consul/aws"
63-
version = "~> 0.8.7"
63+
version = "~> 0.8.8"
6464

6565
hvn = hcp_hvn.main
6666
vpc_id = module.vpc.vpc_id
@@ -88,7 +88,7 @@ resource "aws_key_pair" "hcp_ec2" {
8888
count = local.ssh ? 1 : 0
8989

9090
public_key = tls_private_key.ssh.public_key_openssh
91-
key_name = "hcp-ec2-key"
91+
key_name = "hcp-ec2-key-${local.cluster_id}"
9292
}
9393

9494
resource "local_file" "ssh_key" {
@@ -101,14 +101,14 @@ resource "local_file" "ssh_key" {
101101

102102
module "aws_ec2_consul_client" {
103103
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
104-
version = "~> 0.8.7"
104+
version = "~> 0.8.8"
105105

106106
allowed_http_cidr_blocks = ["0.0.0.0/0"]
107107
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
108108
client_ca_file = hcp_consul_cluster.main.consul_ca_file
109109
client_config_file = hcp_consul_cluster.main.consul_config_file
110110
consul_version = hcp_consul_cluster.main.consul_version
111-
igw_id = module.vpc.igw_id
111+
nat_public_ips = module.vpc.nat_public_ips
112112
install_demo_app = local.install_demo_app
113113
root_token = hcp_consul_cluster_root_token.token.secret_id
114114
security_group_id = module.aws_hcp_consul.security_group_id

hcp-ui-templates/ecs-existing-vpc/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ resource "hcp_hvn" "main" {
4545

4646
module "aws_hcp_consul" {
4747
source = "hashicorp/hcp-consul/aws"
48-
version = "~> 0.8.7"
48+
version = "~> 0.8.8"
4949

5050
hvn = hcp_hvn.main
5151
vpc_id = local.vpc_id
@@ -66,7 +66,7 @@ resource "hcp_consul_cluster_root_token" "token" {
6666

6767
module "aws_ecs_cluster" {
6868
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
69-
version = "~> 0.8.7"
69+
version = "~> 0.8.8"
7070

7171
allowed_http_cidr_blocks = ["0.0.0.0/0"]
7272
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
@@ -77,7 +77,7 @@ module "aws_ecs_cluster" {
7777
consul_url = hcp_consul_cluster.main.consul_private_endpoint_url
7878
consul_version = substr(hcp_consul_cluster.main.consul_version, 1, -1)
7979
datacenter = hcp_consul_cluster.main.datacenter
80-
igw_id = module.vpc.igw_id
80+
nat_public_ips = module.vpc.nat_public_ips
8181
private_subnet_ids = [local.private_subnet1, local.private_subnet2]
8282
public_subnet_ids = [local.public_subnet1, local.public_subnet2]
8383
region = local.vpc_region

hcp-ui-templates/ecs/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ resource "hcp_hvn" "main" {
6060

6161
module "aws_hcp_consul" {
6262
source = "hashicorp/hcp-consul/aws"
63-
version = "~> 0.8.7"
63+
version = "~> 0.8.8"
6464

6565
hvn = hcp_hvn.main
6666
vpc_id = module.vpc.vpc_id
@@ -81,7 +81,7 @@ resource "hcp_consul_cluster_root_token" "token" {
8181

8282
module "aws_ecs_cluster" {
8383
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
84-
version = "~> 0.8.7"
84+
version = "~> 0.8.8"
8585

8686
allowed_http_cidr_blocks = ["0.0.0.0/0"]
8787
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
@@ -92,7 +92,7 @@ module "aws_ecs_cluster" {
9292
consul_url = hcp_consul_cluster.main.consul_private_endpoint_url
9393
consul_version = substr(hcp_consul_cluster.main.consul_version, 1, -1)
9494
datacenter = hcp_consul_cluster.main.datacenter
95-
igw_id = module.vpc.igw_id
95+
nat_public_ips = module.vpc.nat_public_ips
9696
private_subnet_ids = module.vpc.private_subnets
9797
public_subnet_ids = module.vpc.public_subnets
9898
region = local.vpc_region

hcp-ui-templates/eks-existing-vpc/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ resource "hcp_hvn" "main" {
109109

110110
module "aws_hcp_consul" {
111111
source = "hashicorp/hcp-consul/aws"
112-
version = "~> 0.8.7"
112+
version = "~> 0.8.8"
113113

114114
hvn = hcp_hvn.main
115115
vpc_id = local.vpc_id
@@ -131,7 +131,7 @@ resource "hcp_consul_cluster_root_token" "token" {
131131

132132
module "eks_consul_client" {
133133
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
134-
version = "~> 0.8.7"
134+
version = "~> 0.8.8"
135135

136136
boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
137137
cluster_id = hcp_consul_cluster.main.cluster_id
@@ -151,7 +151,7 @@ module "eks_consul_client" {
151151
module "demo_app" {
152152
count = local.install_demo_app ? 1 : 0
153153
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
154-
version = "~> 0.8.7"
154+
version = "~> 0.8.8"
155155

156156
depends_on = [module.eks_consul_client]
157157
}

hcp-ui-templates/eks/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ resource "hcp_hvn" "main" {
126126

127127
module "aws_hcp_consul" {
128128
source = "hashicorp/hcp-consul/aws"
129-
version = "~> 0.8.7"
129+
version = "~> 0.8.8"
130130

131131
hvn = hcp_hvn.main
132132
vpc_id = module.vpc.vpc_id
@@ -148,7 +148,7 @@ resource "hcp_consul_cluster_root_token" "token" {
148148

149149
module "eks_consul_client" {
150150
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
151-
version = "~> 0.8.7"
151+
version = "~> 0.8.8"
152152

153153
boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
154154
cluster_id = hcp_consul_cluster.main.cluster_id
@@ -168,7 +168,7 @@ module "eks_consul_client" {
168168
module "demo_app" {
169169
count = local.install_demo_app ? 1 : 0
170170
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
171-
version = "~> 0.8.7"
171+
version = "~> 0.8.8"
172172

173173
depends_on = [module.eks_consul_client]
174174
}

main.tf

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ data "aws_subnet" "selected" {
6868
}
6969

7070
resource "hcp_hvn_route" "peering_route" {
71-
count = length(var.subnet_ids)
71+
count = length(var.subnet_ids)
72+
7273
hvn_link = var.hvn.self_link
7374
hvn_route_id = var.subnet_ids[count.index]
7475
destination_cidr = data.aws_subnet.selected[count.index].cidr_block
@@ -78,15 +79,17 @@ resource "hcp_hvn_route" "peering_route" {
7879
}
7980

8081
resource "aws_route" "peering" {
81-
count = length(var.route_table_ids)
82+
count = length(var.route_table_ids)
83+
8284
route_table_id = var.route_table_ids[count.index]
8385
destination_cidr_block = var.hvn.cidr_block
8486
vpc_peering_connection_id = aws_vpc_peering_connection_accepter.peer.vpc_peering_connection_id
8587
}
8688

8789
# If a list of security_group_ids was provided, set rules on those.
8890
resource "aws_security_group_rule" "hcp_consul_existing_grp" {
89-
count = length(local.hcp_consul_security_groups)
91+
count = length(local.hcp_consul_security_groups)
92+
9093
description = local.hcp_consul_security_groups[count.index].description
9194
protocol = local.hcp_consul_security_groups[count.index].protocol
9295
security_group_id = local.hcp_consul_security_groups[count.index].security_group_id
@@ -98,15 +101,17 @@ resource "aws_security_group_rule" "hcp_consul_existing_grp" {
98101

99102
# If no security_group_ids were provided, create a new security_group.
100103
resource "aws_security_group" "hcp_consul" {
101-
count = length(var.security_group_ids) == 0 ? 1 : 0
104+
count = length(var.security_group_ids) == 0 ? 1 : 0
105+
102106
name_prefix = "hcp_consul"
103107
description = "HCP Consul security group"
104108
vpc_id = data.aws_vpc.selected.id
105109
}
106110

107111
# If no security_group_ids were provided, use the new security_group.
108-
resource "aws_security_group_rule" "hcp_consul_new_grp" {
109-
count = length(var.security_group_ids) == 0 ? length(local.ingress_consul_rules) : 0
112+
resource "aws_security_group_rule" "allow_lan_consul_gossip" {
113+
count = length(var.security_group_ids) == 0 ? length(local.ingress_consul_rules) : 0
114+
110115
description = local.ingress_consul_rules[count.index].description
111116
protocol = local.ingress_consul_rules[count.index].protocol
112117
security_group_id = aws_security_group.hcp_consul[0].id

0 commit comments

Comments
 (0)