remove bot, force role order

This commit is contained in:
41666 2023-05-28 09:47:19 -04:00
parent 677d91b17b
commit dc1e7718bc
13 changed files with 15 additions and 1659 deletions

View file

@ -1,114 +0,0 @@
locals {
botTag = var.bot_tag == "" ? ":main" : var.bot_tag
botRegion = var.gcp_region
}
data "google_compute_zones" "gcp_zones" {
region = local.botRegion
status = "UP"
}
resource "random_integer" "zone_index" {
min = 0
max = length(data.google_compute_zones.gcp_zones.names) - 1
keepers = {
region = local.botRegion
envtag = var.environment_tag
}
}
data "google_compute_subnetwork" "default_subnet" {
name = "default"
region = local.botRegion
}
data "google_compute_default_service_account" "default_service_account" {
}
resource "random_pet" "name" {
keepers = {
region = local.botRegion
envtag = var.environment_tag
version = local.botTag
}
}
locals {
instance_name = "roleypoly-bot-${var.environment_tag}-${random_pet.name.id}"
}
module "gce_container" {
source = "terraform-google-modules/container-vm/google"
version = ">=3.0.0"
// https://cloud.google.com/container-optimized-os/docs/release-notes/m93#cos-93-16623-102-5
cos_image_name = "cos-93-16623-102-5"
container = {
image = "ghcr.io/roleypoly/bot${local.botTag}"
env = [
{
name = "BOT_TOKEN",
value = var.bot_token
},
{
name = "BOT_CLIENT_ID",
value = var.bot_client_id
},
{
name = "UI_PUBLIC_URI",
value = var.ui_public_uri
}
]
}
restart_policy = "Always"
}
resource "google_compute_instance" "vm" {
count = var.deploy_bot ? 1 : 0
project = var.gcp_project
name = local.instance_name
machine_type = var.bot_instance_size
zone = data.google_compute_zones.gcp_zones.names[random_integer.zone_index.result]
allow_stopping_for_update = true
boot_disk {
initialize_params {
image = module.gce_container.source_image
}
}
network_interface {
subnetwork = data.google_compute_subnetwork.default_subnet.self_link
access_config {
network_tier = "STANDARD"
}
}
metadata = {
gce-container-declaration = module.gce_container.metadata_value
google-logging-enabled = "true"
google-monitoring-enabled = "true"
}
labels = {
container-vm = module.gce_container.vm_container_label
}
service_account {
email = data.google_compute_default_service_account.default_service_account.email
scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
"https://www.googleapis.com/auth/trace.append",
]
}
lifecycle {
create_before_destroy = true
}
}

View file

@ -58,24 +58,6 @@ variable "root_users" {
description = "Root users to use for role elevation calculations"
}
variable "deploy_bot" {
type = bool
default = false
description = "Bot is an optional piece of the system. It's only typically deployed in prod."
}
variable "bot_instance_size" {
type = string
default = "f1-micro"
description = "Google Compute Engine VM size"
}
variable "bot_tag" {
type = string
default = ""
description = ":tag or @sha265: of ghcr.io/roleypoly/bot"
}
variable "worker_tag" {
type = string
default = ""

View file

@ -1,5 +1,5 @@
environment_tag = "prod"
deploy_bot = true
deploy_bot = false
bot_instance_size = "e2-small"
ui_public_uri = "https://roleypoly.com"
api_public_uri = "https://api-prod.roleypoly.com"

View file

@ -1,5 +1,5 @@
environment_tag = "stage"
deploy_bot = true
deploy_bot = false
bot_instance_size = "e2-micro"
ui_public_uri = "https://stage.roleypoly.com"
api_public_uri = "https://api-stage.roleypoly.com"