feat(terraform): convert 01-setupenv.sh to terraform
This commit is contained in:
parent
c24417b5e3
commit
99518934fb
60
infrastructure/terraform/main.tf
Normal file
60
infrastructure/terraform/main.tf
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
provider "google" {
|
||||||
|
project = var.project_id
|
||||||
|
region = var.region
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_project_service" "apis" {
|
||||||
|
for_each = toset([
|
||||||
|
"aiplatform.googleapis.com",
|
||||||
|
"storage.googleapis.com",
|
||||||
|
"cloudbilling.googleapis.com",
|
||||||
|
"cloudresourcemanager.googleapis.com",
|
||||||
|
"iam.googleapis.com",
|
||||||
|
"run.googleapis.com",
|
||||||
|
"artifactregistry.googleapis.com",
|
||||||
|
"cloudbuild.googleapis.com",
|
||||||
|
"cloudbuildv2.googleapis.com",
|
||||||
|
"secretmanager.googleapis.com",
|
||||||
|
"monitoring.googleapis.com",
|
||||||
|
"logging.googleapis.com",
|
||||||
|
"cloudtrace.googleapis.com",
|
||||||
|
"pubsub.googleapis.com",
|
||||||
|
"cloudfunctions.googleapis.com",
|
||||||
|
])
|
||||||
|
service = each.key
|
||||||
|
disable_dependent_services = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_service_account" "agent_sa" {
|
||||||
|
account_id = "osvauco-agent-sa"
|
||||||
|
display_name = "OSVauco Agent Runner SA"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_project_iam_member" "agent_sa_roles" {
|
||||||
|
for_each = toset([
|
||||||
|
"roles/aiplatform.user",
|
||||||
|
"roles/storage.objectAdmin",
|
||||||
|
"roles/logging.logWriter",
|
||||||
|
"roles/cloudtrace.agent",
|
||||||
|
"roles/monitoring.metricWriter",
|
||||||
|
"roles/secretmanager.secretAccessor",
|
||||||
|
"roles/run.invoker",
|
||||||
|
])
|
||||||
|
project = var.project_id
|
||||||
|
role = each.key
|
||||||
|
member = "serviceAccount:${google_service_account.agent_sa.email}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_pubsub_topic" "billing_alerts" {
|
||||||
|
name = "billing-alert-auto-teardown"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_pubsub_subscription" "billing_alerts_sub" {
|
||||||
|
name = "billing-alert-subscription"
|
||||||
|
topic = google_pubsub_topic.billing_alerts.name
|
||||||
|
|
||||||
|
# Push to an email address
|
||||||
|
push_config {
|
||||||
|
push_endpoint = "mailto:${var.alert_email}"
|
||||||
|
}
|
||||||
|
}
|
||||||
26
infrastructure/terraform/variables.tf
Normal file
26
infrastructure/terraform/variables.tf
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
variable "project_id" {
|
||||||
|
description = "The project ID to deploy the resources to."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "region" {
|
||||||
|
description = "The region to deploy the resources to."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "customer_id" {
|
||||||
|
description = "The customer ID for billing and labeling."
|
||||||
|
type = string
|
||||||
|
default = "osvauco"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "alert_email" {
|
||||||
|
description = "The email address for billing alerts."
|
||||||
|
type = string
|
||||||
|
default = "billing-alerts@example.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "billing_account_id" {
|
||||||
|
description = "The billing account ID to associate with the project."
|
||||||
|
type = string
|
||||||
|
}
|
||||||
10
infrastructure/terraform/versions.tf
Normal file
10
infrastructure/terraform/versions.tf
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
terraform {
|
||||||
|
required_version = ">= 1.5"
|
||||||
|
|
||||||
|
required_providers {
|
||||||
|
google = {
|
||||||
|
source = "hashicorp/google"
|
||||||
|
version = ">= 5.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user