Skip to content

Commit edbba0d

Browse files
committed
add multi-network gateway
1 parent 4506edb commit edbba0d

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

resources/terraform/auto-drive/main.tf

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,43 @@ module "ec2_gateway" {
209209
)
210210
tags = merge(local.tags, { Role = "gateway" })
211211
}
212+
213+
################################################################################
214+
# Multi-Network Gateway Instances
215+
################################################################################
216+
217+
module "ec2_multi_gateway" {
218+
source = "../../../templates/terraform/aws/ec2"
219+
name = "${local.name}-multi-network-gateway"
220+
count = var.multi_network_gateway_instance_count
221+
ami = data.aws_ami.ubuntu_amd64.id
222+
instance_type = var.multi_network_gateway_instance_type
223+
availability_zone = element(module.vpc.azs, 0)
224+
subnet_id = element(module.vpc.public_subnets, 0)
225+
vpc_security_group_ids = [aws_security_group.auto_drive_sg.id]
226+
associate_public_ip_address = false # Gateway instances use EIPs
227+
create_eip = true
228+
disable_api_stop = false
229+
230+
create_iam_instance_profile = true
231+
ignore_ami_changes = true
232+
iam_role_description = "IAM role for EC2 instance"
233+
iam_role_policies = {
234+
AdministratorAccess = "arn:aws:iam::aws:policy/AdministratorAccess"
235+
}
236+
237+
root_block_device = [
238+
{
239+
device_name = "/dev/sdf"
240+
encrypted = true
241+
volume_type = "gp3"
242+
throughput = 250
243+
volume_size = var.gateway_root_volume_size
244+
}
245+
]
246+
volume_tags = merge(
247+
{ "Name" = "${local.name}-multi-network-gateway-root-volume-${count.index}" },
248+
var.tags
249+
)
250+
tags = merge(local.tags, { Role = "multi-network-gateway" })
251+
}

resources/terraform/auto-drive/variables.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ variable "gateway_instance_type" {
4848
default = "m7a.2xlarge"
4949
}
5050

51+
# Gateway Instance Configuration
52+
variable "multi_network_gateway_instance_type" {
53+
description = "Instance type for gateway instances."
54+
type = string
55+
default = "t3.medium"
56+
}
57+
5158
variable "gateway_root_volume_size" {
5259
description = "Size of the root volume (in GB) for gateway instances."
5360
type = number
@@ -79,6 +86,12 @@ variable "gateway_instance_count" {
7986
default = 1
8087
}
8188

89+
variable "multi_network_gateway_instance_count" {
90+
description = "Number of multi-network gateway instances to create."
91+
type = number
92+
default = 1
93+
}
94+
8295
variable "ingress_cidr_blocks" {
8396
description = "List of CIDR blocks for ingress"
8497
type = list(string)

templates/terraform/aws/ec2/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ resource "aws_instance" "this" {
197197
private_ip,
198198
associate_public_ip_address,
199199
vpc_security_group_ids,
200+
instance_type,
200201
]
201202
}
202203
}
@@ -384,6 +385,7 @@ resource "aws_instance" "ignore_ami" {
384385
private_ip,
385386
associate_public_ip_address,
386387
vpc_security_group_ids,
388+
instance_type,
387389
]
388390
}
389391
}

0 commit comments

Comments
 (0)