Skip to content

Commit 59cbd51

Browse files
author
Joshua Timmons
authored
Add instance dependency on IGW (#64)
1 parent c207633 commit 59cbd51

File tree

23 files changed

+153
-136
lines changed

23 files changed

+153
-136
lines changed

examples/hcp-ec2-demo/main.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ module "vpc" {
99
source = "terraform-aws-modules/vpc/aws"
1010
version = "3.10.0"
1111

12-
name = "${var.cluster_id}-vpc"
13-
cidr = "10.0.0.0/16"
1412
azs = data.aws_availability_zones.available.names
15-
public_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
16-
private_subnets = []
13+
cidr = "10.0.0.0/16"
1714
enable_dns_hostnames = true
15+
name = "${var.cluster_id}-vpc"
16+
private_subnets = []
17+
public_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
1818
}
1919

2020
resource "hcp_hvn" "main" {
@@ -26,7 +26,7 @@ resource "hcp_hvn" "main" {
2626

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

3131
hvn = hcp_hvn.main
3232
vpc_id = module.vpc.vpc_id
@@ -51,27 +51,30 @@ resource "tls_private_key" "ssh" {
5151
}
5252

5353
resource "aws_key_pair" "hcp_ec2" {
54-
count = var.ssh ? 1 : 0
55-
key_name = "hcp-ec2-key"
54+
count = var.ssh ? 1 : 0
55+
5656
public_key = tls_private_key.ssh.public_key_openssh
57+
key_name = "hcp-ec2-key"
5758
}
5859

5960
resource "local_file" "ssh_key" {
60-
count = var.ssh ? 1 : 0
61-
filename = "${path.module}/${aws_key_pair.hcp_ec2[0].key_name}.pem"
61+
count = var.ssh ? 1 : 0
62+
6263
content = tls_private_key.ssh.private_key_pem
6364
file_permission = "400"
65+
filename = "${path.module}/${aws_key_pair.hcp_ec2[0].key_name}.pem"
6466
}
6567

6668
module "aws_ec2_consul_client" {
6769
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
68-
version = "~> 0.8.6"
70+
version = "~> 0.8.7"
6971

7072
allowed_http_cidr_blocks = ["0.0.0.0/0"]
7173
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
7274
client_ca_file = hcp_consul_cluster.main.consul_ca_file
7375
client_config_file = hcp_consul_cluster.main.consul_config_file
7476
consul_version = hcp_consul_cluster.main.consul_version
77+
igw_id = module.vpc.igw_id
7578
install_demo_app = var.install_demo_app
7679
root_token = hcp_consul_cluster_root_token.token.secret_id
7780
security_group_id = module.aws_hcp_consul.security_group_id

examples/hcp-ecs-demo/main.tf

Lines changed: 3 additions & 2 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.6"
31+
version = "~> 0.8.7"
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.6"
52+
version = "~> 0.8.7"
5353

5454
allowed_http_cidr_blocks = ["0.0.0.0/0"]
5555
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
@@ -60,6 +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
6364
private_subnet_ids = module.vpc.private_subnets
6465
public_subnet_ids = module.vpc.public_subnets
6566
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.6"
66+
version = "~> 0.8.7"
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.6"
88+
version = "~> 0.8.7"
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.6"
108+
version = "~> 0.8.7"
109109

110110
depends_on = [module.eks_consul_client]
111111
}

examples/hcp-eks-demo/variables.tf

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ variable "cluster_id" {
44
default = "cluster-eks-demo"
55
}
66

7-
variable "vpc_region" {
8-
type = string
9-
description = "The AWS region to create resources in"
10-
default = "us-west-2"
11-
}
12-
13-
variable "hvn_region" {
7+
variable "hvn_cidr_block" {
148
type = string
15-
description = "The HCP region to create resources in"
16-
default = "us-west-2"
9+
description = "The CIDR range to create the HCP HVN with"
10+
default = "172.25.32.0/20"
1711
}
1812

1913
variable "hvn_id" {
@@ -22,16 +16,10 @@ variable "hvn_id" {
2216
default = "cluster-eks-demo-hvn"
2317
}
2418

25-
variable "hvn_cidr_block" {
26-
type = string
27-
description = "The CIDR range to create the HCP HVN with"
28-
default = "172.25.32.0/20"
29-
}
30-
31-
variable "tier" {
19+
variable "hvn_region" {
3220
type = string
33-
description = "The HCP Consul tier to use when creating a Consul cluster"
34-
default = "development"
21+
description = "The HCP region to create resources in"
22+
default = "us-west-2"
3523
}
3624

3725
variable "install_demo_app" {
@@ -45,3 +33,15 @@ variable "install_eks_cluster" {
4533
description = "Choose if you want an eks cluster to be provisioned"
4634
default = true
4735
}
36+
37+
variable "tier" {
38+
type = string
39+
description = "The HCP Consul tier to use when creating a Consul cluster"
40+
default = "development"
41+
}
42+
43+
variable "vpc_region" {
44+
type = string
45+
description = "The AWS region to create resources in"
46+
default = "us-west-2"
47+
}

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

Lines changed: 9 additions & 6 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.6"
48+
version = "~> 0.8.7"
4949

5050
hvn = hcp_hvn.main
5151
vpc_id = local.vpc_id
@@ -70,27 +70,30 @@ resource "tls_private_key" "ssh" {
7070
}
7171

7272
resource "aws_key_pair" "hcp_ec2" {
73-
count = local.ssh ? 1 : 0
74-
key_name = "hcp-ec2-key"
73+
count = local.ssh ? 1 : 0
74+
7575
public_key = tls_private_key.ssh.public_key_openssh
76+
key_name = "hcp-ec2-key"
7677
}
7778

7879
resource "local_file" "ssh_key" {
79-
count = local.ssh ? 1 : 0
80-
filename = "${path.module}/${aws_key_pair.hcp_ec2[0].key_name}.pem"
80+
count = local.ssh ? 1 : 0
81+
8182
content = tls_private_key.ssh.private_key_pem
8283
file_permission = "400"
84+
filename = "${path.module}/${aws_key_pair.hcp_ec2[0].key_name}.pem"
8385
}
8486

8587
module "aws_ec2_consul_client" {
8688
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
87-
version = "~> 0.8.6"
89+
version = "~> 0.8.7"
8890

8991
allowed_http_cidr_blocks = ["0.0.0.0/0"]
9092
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
9193
client_ca_file = hcp_consul_cluster.main.consul_ca_file
9294
client_config_file = hcp_consul_cluster.main.consul_config_file
9395
consul_version = hcp_consul_cluster.main.consul_version
96+
igw_id = module.vpc.igw_id
9497
install_demo_app = local.install_demo_app
9598
root_token = hcp_consul_cluster_root_token.token.secret_id
9699
security_group_id = module.aws_hcp_consul.security_group_id

hcp-ui-templates/ec2/main.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ module "vpc" {
4343
source = "terraform-aws-modules/vpc/aws"
4444
version = "3.10.0"
4545

46-
name = "${local.cluster_id}-vpc"
47-
cidr = "10.0.0.0/16"
4846
azs = data.aws_availability_zones.available.names
49-
public_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
50-
private_subnets = []
47+
cidr = "10.0.0.0/16"
5148
enable_dns_hostnames = true
49+
name = "${local.cluster_id}-vpc"
50+
private_subnets = []
51+
public_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
5252
}
5353

5454
resource "hcp_hvn" "main" {
@@ -60,7 +60,7 @@ resource "hcp_hvn" "main" {
6060

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

6565
hvn = hcp_hvn.main
6666
vpc_id = module.vpc.vpc_id
@@ -85,27 +85,30 @@ resource "tls_private_key" "ssh" {
8585
}
8686

8787
resource "aws_key_pair" "hcp_ec2" {
88-
count = local.ssh ? 1 : 0
89-
key_name = "hcp-ec2-key"
88+
count = local.ssh ? 1 : 0
89+
9090
public_key = tls_private_key.ssh.public_key_openssh
91+
key_name = "hcp-ec2-key"
9192
}
9293

9394
resource "local_file" "ssh_key" {
94-
count = local.ssh ? 1 : 0
95-
filename = "${path.module}/${aws_key_pair.hcp_ec2[0].key_name}.pem"
95+
count = local.ssh ? 1 : 0
96+
9697
content = tls_private_key.ssh.private_key_pem
9798
file_permission = "400"
99+
filename = "${path.module}/${aws_key_pair.hcp_ec2[0].key_name}.pem"
98100
}
99101

100102
module "aws_ec2_consul_client" {
101103
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
102-
version = "~> 0.8.6"
104+
version = "~> 0.8.7"
103105

104106
allowed_http_cidr_blocks = ["0.0.0.0/0"]
105107
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
106108
client_ca_file = hcp_consul_cluster.main.consul_ca_file
107109
client_config_file = hcp_consul_cluster.main.consul_config_file
108110
consul_version = hcp_consul_cluster.main.consul_version
111+
igw_id = module.vpc.igw_id
109112
install_demo_app = local.install_demo_app
110113
root_token = hcp_consul_cluster_root_token.token.secret_id
111114
security_group_id = module.aws_hcp_consul.security_group_id

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

Lines changed: 3 additions & 2 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.6"
48+
version = "~> 0.8.7"
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.6"
69+
version = "~> 0.8.7"
7070

7171
allowed_http_cidr_blocks = ["0.0.0.0/0"]
7272
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
@@ -77,6 +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
8081
private_subnet_ids = [local.private_subnet1, local.private_subnet2]
8182
public_subnet_ids = [local.public_subnet1, local.public_subnet2]
8283
region = local.vpc_region

hcp-ui-templates/ecs/main.tf

Lines changed: 3 additions & 2 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.6"
63+
version = "~> 0.8.7"
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.6"
84+
version = "~> 0.8.7"
8585

8686
allowed_http_cidr_blocks = ["0.0.0.0/0"]
8787
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
@@ -92,6 +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
9596
private_subnet_ids = module.vpc.private_subnets
9697
public_subnet_ids = module.vpc.public_subnets
9798
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.6"
112+
version = "~> 0.8.7"
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.6"
134+
version = "~> 0.8.7"
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.6"
154+
version = "~> 0.8.7"
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.6"
129+
version = "~> 0.8.7"
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.6"
151+
version = "~> 0.8.7"
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.6"
171+
version = "~> 0.8.7"
172172

173173
depends_on = [module.eks_consul_client]
174174
}

0 commit comments

Comments
 (0)