Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit a5b7086

Browse files
committed
Use only predefined VPC
1 parent e20afae commit a5b7086

File tree

17 files changed

+152
-197
lines changed

17 files changed

+152
-197
lines changed

terraform/aws/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ email = "[email protected]"
133133
Deploy to existing VPC.
134134

135135
```hcl
136-
predefined_vpc = {
137-
id = "vpc-***",
138-
subnet_public_ids = ["subnet-***", "subnet-***", "subnet-***"],
139-
subnet_private_ids = ["subnet-***", "subnet-***", "subnet-***"],
140-
}
136+
predefined_vpc_id = "vpc-***"
141137
```
142138

143139
[Full tfvars file example](examples/opensource_predefined_vpc.tfvars)

terraform/aws/env/.terraform.lock.hcl

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/aws/env/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
| <a name="input_postgresql_type"></a> [postgresql\_type](#input\_postgresql\_type) | Postgresql type | `string` | `"internal"` | no |
9393
| <a name="input_postgresql_username"></a> [postgresql\_username](#input\_postgresql\_username) | Postgresql username | `string` | `"labelstudio"` | no |
9494
| <a name="input_predefined_s3_bucket"></a> [predefined\_s3\_bucket](#input\_predefined\_s3\_bucket) | Predefined S3 Bucket | <pre>object(<br> {<br> name : string<br> region : string<br> folder : string<br> kms_arn : string<br> }<br> )</pre> | `null` | no |
95-
| <a name="input_predefined_vpc"></a> [predefined\_vpc](#input\_predefined\_vpc) | Predefined VPC | <pre>object(<br> {<br> id : string<br> subnet_public_ids : list(string)<br> subnet_private_ids : list(string)<br> }<br> )</pre> | `null` | no |
95+
| <a name="input_predefined_vpc_id"></a> [predefined\_vpc\_id](#input\_predefined\_vpc\_id) | Predefined VPC | `string` | `null` | no |
9696
| <a name="input_private_cidr_block"></a> [private\_cidr\_block](#input\_private\_cidr\_block) | List of private subnet cidr blocks | `list(string)` | <pre>[<br> "10.0.1.0/24",<br> "10.0.2.0/24",<br> "10.0.3.0/24"<br>]</pre> | no |
9797
| <a name="input_public_cidr_block"></a> [public\_cidr\_block](#input\_public\_cidr\_block) | List of public subnet cidr blocks | `list(string)` | <pre>[<br> "10.0.101.0/24",<br> "10.0.102.0/24",<br> "10.0.103.0/24"<br>]</pre> | no |
9898
| <a name="input_record_name"></a> [record\_name](#input\_record\_name) | Main record domain name | `string` | `null` | no |

terraform/aws/env/main.tf

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,19 @@ locals {
1717
redis_password = var.redis_password == null ? random_password.redis_password[0].result : var.redis_password
1818
}
1919

20-
# Create VPC
20+
# Create and/or configure VPC
2121
module "vpc" {
22-
source = "../modules/vpc"
23-
providers = {
24-
aws = aws.aws_ignore_tags
25-
}
26-
27-
count = var.predefined_vpc == null ? 1 : 0
22+
source = "../modules/vpc"
2823

2924
name = local.name_prefix
3025
environment = var.environment
3126
region = var.region
3227
public_cidr_block = var.public_cidr_block
3328
private_cidr_block = var.private_cidr_block
3429
tags = local.tags
30+
31+
# Predefined VPC
32+
predefined_vpc_id = var.predefined_vpc_id
3533
}
3634

3735
# Create Identity Access Management
@@ -88,9 +86,9 @@ module "eks" {
8886
min_size = var.min_size
8987
role_arn = module.iam.role_arn
9088
worker_role_arn = module.iam.worker_role_arn
91-
public_subnets = var.predefined_vpc == null ? module.vpc[0].aws_subnet_public_ids : var.predefined_vpc.subnet_public_ids
92-
subnet_ids = var.predefined_vpc == null ? module.vpc[0].aws_subnet_private_ids : var.predefined_vpc.subnet_private_ids
93-
vpc_id = var.predefined_vpc == null ? module.vpc[0].aws_vpc_id : var.predefined_vpc.id
89+
public_subnets = module.vpc.aws_subnet_public_ids
90+
subnet_ids = module.vpc.aws_subnet_private_ids
91+
vpc_id = module.vpc.aws_vpc_id
9492
instance_profile_name = module.iam.iam_instance_profile
9593
tags = local.tags
9694
capacity_type = var.eks_capacity_type
@@ -136,8 +134,8 @@ module "rds" {
136134

137135
name = local.name_prefix
138136
environment = var.environment
139-
vpc_id = var.predefined_vpc == null ? module.vpc[0].aws_vpc_id : var.predefined_vpc.id
140-
subnet_ids = var.predefined_vpc == null ? module.vpc[0].aws_subnet_private_ids : var.predefined_vpc.subnet_private_ids
137+
vpc_id = module.vpc.aws_vpc_id
138+
subnet_ids = module.vpc.aws_subnet_private_ids
141139
machine_type = var.postgresql_machine_type
142140
database = var.postgresql_database
143141
username = var.postgresql_username
@@ -155,8 +153,8 @@ module "elasticache" {
155153
count = var.redis_type == "elasticache" && var.enterprise ? 1 : 0
156154

157155
name = local.name_prefix
158-
vpc_id = var.predefined_vpc == null ? module.vpc[0].aws_vpc_id : var.predefined_vpc.id
159-
subnet_ids = var.predefined_vpc == null ? module.vpc[0].aws_subnet_private_ids : var.predefined_vpc.subnet_private_ids
156+
vpc_id = module.vpc.aws_vpc_id
157+
subnet_ids = module.vpc.aws_subnet_private_ids
160158
machine_type = var.redis_machine_type
161159
port = var.redis_port
162160
password = local.redis_password
@@ -179,8 +177,6 @@ module "lbc" {
179177
module.eks,
180178
module.vpc,
181179
]
182-
public_subnets = var.predefined_vpc == null ? module.vpc[0].aws_subnet_public_ids : var.predefined_vpc.subnet_public_ids
183-
private_subnets = var.predefined_vpc == null ? module.vpc[0].aws_subnet_private_ids : var.predefined_vpc.subnet_private_ids
184180
}
185181

186182
module "nic" {
@@ -209,7 +205,7 @@ module "cert-manager" {
209205
}
210206

211207
module "label-studio" {
212-
count = var.deploy_label_studio ? 1 : 0
208+
count = var.deploy_label_studio ? 1 : 0
213209

214210
source = "../../common/modules/label-studio"
215211

terraform/aws/env/providers.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ provider "aws" {
22
region = var.region
33
}
44

5-
provider "aws" {
6-
alias = "aws_ignore_tags"
7-
region = var.region
8-
ignore_tags {
9-
key_prefixes = ["kubernetes.io/"]
10-
}
11-
}
12-
135
provider "kubernetes" {
146
host = data.aws_eks_cluster.eks.endpoint
157
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks.certificate_authority[0].data)

terraform/aws/env/variables.tf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,8 @@ variable "lets_encrypt_email" {
321321
}
322322

323323
# Predefined VPC
324-
variable "predefined_vpc" {
325-
type = object(
326-
{
327-
id : string
328-
subnet_public_ids : list(string)
329-
subnet_private_ids : list(string)
330-
}
331-
)
324+
variable "predefined_vpc_id" {
325+
type = string
332326
default = null
333327
}
334328

terraform/aws/examples/only_infrastructure.tfvars

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ name = "ls"
77
region = "us-east-2"
88

99
# Predefined VPC
10-
predefined_vpc = {
11-
id = "vpc-11111111",
12-
subnet_public_ids = ["subnet-11111111", "subnet-2222222", "subnet-33333333"],
13-
subnet_private_ids = ["subnet-44444444", "subnet-5555555", "subnet-77777777"],
14-
}
10+
predefined_vpc_id = "vpc-***"
1511

1612
deploy_label_studio = false
1713
postgresql_type = "external"

terraform/aws/examples/opensource_predefined_vpc.tfvars

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,4 @@ label_studio_additional_set = {
1212
}
1313

1414
# Predefined VPC
15-
predefined_vpc = {
16-
id = "vpc-***",
17-
subnet_public_ids = ["subnet-***", "subnet-***", "subnet-***"],
18-
subnet_private_ids = ["subnet-***", "subnet-***", "subnet-***"],
19-
}
15+
predefined_vpc_id = "vpc-***"

terraform/aws/modules/eks/security_groups.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ resource "aws_security_group_rule" "cluster_security_group_rule" {
9393
source_security_group_id = aws_security_group.worker_security_group.id
9494
to_port = 65535
9595
type = "ingress"
96-
}
96+
}

terraform/aws/modules/eks/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ variable "cluster_api_cidr" {
145145
description = "Allow workstation to communicate with the cluster API Server"
146146
type = string
147147
default = "10.2.0.0/32"
148-
}
148+
}

terraform/aws/modules/load-balancer-controller/subnets.tf

Lines changed: 0 additions & 20 deletions
This file was deleted.

terraform/aws/modules/load-balancer-controller/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,3 @@ variable "namespace" {
4444
type = string
4545
default = "ingress"
4646
}
47-
48-
variable "private_subnets" {
49-
type = list(string)
50-
description = "List of private subnets"
51-
}
52-
53-
variable "public_subnets" {
54-
type = list(string)
55-
description = "List of public subnets"
56-
}

terraform/aws/modules/vpc/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ No modules.
3434
| [aws_subnet.public_subnet](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/subnet) | resource |
3535
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc) | resource |
3636
| [aws_availability_zones.availability_zones](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
37+
| [aws_vpc.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
3738

3839
## Inputs
3940

@@ -43,6 +44,7 @@ No modules.
4344
| <a name="input_environment"></a> [environment](#input\_environment) | Name of the environment where infrastructure is being built | `string` | n/a | yes |
4445
| <a name="input_multi_az_nat_gateway"></a> [multi\_az\_nat\_gateway](#input\_multi\_az\_nat\_gateway) | place a NAT gateway in each AZ | `number` | `1` | no |
4546
| <a name="input_name"></a> [name](#input\_name) | Name is the prefix to use for resources that needs to be created | `string` | n/a | yes |
47+
| <a name="input_predefined_vpc_id"></a> [predefined\_vpc\_id](#input\_predefined\_vpc\_id) | Predefined VPC ID | `string` | n/a | yes |
4648
| <a name="input_private_cidr_block"></a> [private\_cidr\_block](#input\_private\_cidr\_block) | List of private subnet CIDR blocks | `list(string)` | n/a | yes |
4749
| <a name="input_public_cidr_block"></a> [public\_cidr\_block](#input\_public\_cidr\_block) | List of public subnet CIDR blocks | `list(string)` | n/a | yes |
4850
| <a name="input_region"></a> [region](#input\_region) | The AWS region in where terraform builds resources | `string` | n/a | yes |
@@ -65,6 +67,5 @@ No modules.
6567
| <a name="output_aws_route_table_public_ids"></a> [aws\_route\_table\_public\_ids](#output\_aws\_route\_table\_public\_ids) | Output attributes of the route table ids. |
6668
| <a name="output_aws_subnet_private_ids"></a> [aws\_subnet\_private\_ids](#output\_aws\_subnet\_private\_ids) | n/a |
6769
| <a name="output_aws_subnet_public_ids"></a> [aws\_subnet\_public\_ids](#output\_aws\_subnet\_public\_ids) | Output attributes of the public and private subnets |
68-
| <a name="output_aws_vpc_cidr"></a> [aws\_vpc\_cidr](#output\_aws\_vpc\_cidr) | Output attribute of the VPC cidr block. |
6970
| <a name="output_aws_vpc_id"></a> [aws\_vpc\_id](#output\_aws\_vpc\_id) | Output attribute id of the VPC |
7071
<!-- END_TF_DOCS -->

terraform/aws/modules/vpc/outputs.tf

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Output attribute id of the VPC
22
output "aws_vpc_id" {
3-
value = aws_vpc.vpc.id
4-
}
5-
# Output attribute of the VPC cidr block.
6-
output "aws_vpc_cidr" {
7-
value = aws_vpc.vpc.cidr_block
3+
value = local.vpc_id
84
}
95

106
# Output attributes of the public and private subnets

0 commit comments

Comments
 (0)