Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(rnd, infra) Add static ips module (#7588)

Aarushif40db85b4382
diff --git a/rnd/infra/terraform/environments/dev.tfvars b/rnd/infra/terraform/environments/dev.tfvars
index 0082681b18..cbcc69ccd8 100644
--- a/rnd/infra/terraform/environments/dev.tfvars
+++ b/rnd/infra/terraform/environments/dev.tfvars
@@ -1,11 +1,12 @@
-project_id = "agpt-dev"
-region = "us-central1"
-zone = "us-central1-a"
-network_name = "dev-gke-network"
-subnet_name = "dev-gke-subnet"
-subnet_cidr = "10.0.0.0/24"
-cluster_name = "dev-gke-cluster"
-node_count = 2
-node_pool_name = "dev-main-pool"
-machine_type = "e2-medium"
-disk_size_gb = 100
+project_id = "agpt-dev"
+region = "us-central1"
+zone = "us-central1-a"
+network_name = "dev-gke-network"
+subnet_name = "dev-gke-subnet"
+subnet_cidr = "10.0.0.0/24"
+cluster_name = "dev-gke-cluster"
+node_count = 2
+node_pool_name = "dev-main-pool"
+machine_type = "e2-medium"
+disk_size_gb = 100
+static_ip_names = ["agpt-server-ip", "agpt-builder-ip", "auth-ip"]
diff --git a/rnd/infra/terraform/main.tf b/rnd/infra/terraform/main.tf
index 474a76c205..856372e10c 100644
--- a/rnd/infra/terraform/main.tf
+++ b/rnd/infra/terraform/main.tf
@@ -17,6 +17,14 @@ provider "google" {
zone = var.zone
}
+module "static_ips" {
+ source = "./modules/static_ip"
+
+ project_id = var.project_id
+ ip_names = var.static_ip_names
+ region = var.region
+}
+
module "networking" {
source = "./modules/networking"
diff --git a/rnd/infra/terraform/modules/static_ip/main.tf b/rnd/infra/terraform/modules/static_ip/main.tf
new file mode 100644
index 0000000000..4b6d073541
--- /dev/null
+++ b/rnd/infra/terraform/modules/static_ip/main.tf
@@ -0,0 +1,6 @@
+resource "google_compute_address" "static_ip" {
+ count = length(var.ip_names)
+ name = "${var.project_id}-${var.ip_names[count.index]}"
+ region = var.region
+ address_type = "EXTERNAL"
+}
\ No newline at end of file
diff --git a/rnd/infra/terraform/modules/static_ip/outputs.tf b/rnd/infra/terraform/modules/static_ip/outputs.tf
new file mode 100644
index 0000000000..2b03fe3623
--- /dev/null
+++ b/rnd/infra/terraform/modules/static_ip/outputs.tf
@@ -0,0 +1,9 @@
+output "ip_addresses" {
+ description = "Map of created static IP addresses"
+ value = { for i, ip in google_compute_address.static_ip : var.ip_names[i] => ip.address }
+}
+
+output "ip_names" {
+ description = "List of full names of the created static IP addresses"
+ value = google_compute_address.static_ip[*].name
+}
\ No newline at end of file
diff --git a/rnd/infra/terraform/modules/static_ip/variables.tf b/rnd/infra/terraform/modules/static_ip/variables.tf
new file mode 100644
index 0000000000..4cc6607a4d
--- /dev/null
+++ b/rnd/infra/terraform/modules/static_ip/variables.tf
@@ -0,0 +1,14 @@
+variable "project_id" {
+ description = "The project ID to prepend to IP names"
+ type = string
+}
+
+variable "ip_names" {
+ description = "List of custom names for static IPs"
+ type = list(string)
+}
+
+variable "region" {
+ description = "Region to create the static IPs in"
+ type = string
+}
diff --git a/rnd/infra/terraform/variables.tf b/rnd/infra/terraform/variables.tf
index 23c48e9086..66c35e7ad6 100644
--- a/rnd/infra/terraform/variables.tf
+++ b/rnd/infra/terraform/variables.tf
@@ -68,3 +68,9 @@ variable "enable_autopilot" {
type = bool
default = false
}
+
+variable "static_ip_names" {
+ description = "List of custom names for static IPs"
+ type = list(string)
+ default = ["ip-1", "ip-2", "ip-3"]
+}