Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tf/deployment/modules/scoped/discord/community/channels.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ locals {
"yucca_off_topic",
"yucca_focus_topic",
"yucca_alerts",
"yucca_alerts_testing",
"yucca_alerts_staging",
"yucca_alerts_dev",
]
# Leadership
Expand Down Expand Up @@ -333,7 +333,7 @@ module "team_channels_write" {
yucca_off_topic = discord_text_channel.yucca_off_topic.id
yucca_focus_topic = discord_forum_channel.yucca_focus_topic.id
yucca_alerts = discord_text_channel.yucca_alerts.id
yucca_alerts_testing = discord_text_channel.yucca_alerts_testing.id
yucca_alerts_staging = discord_text_channel.yucca_alerts_staging.id
yucca_alerts_dev = discord_text_channel.yucca_alerts_dev.id
yucca_voice = discord_voice_channel.yucca_voice.id
}
Expand Down Expand Up @@ -796,9 +796,9 @@ resource "discord_text_channel" "yucca_alerts" {
}
}

resource "discord_text_channel" "yucca_alerts_testing" {
name = "yucca-alerts-testing"
position = index(local.channel_order.yucca, "yucca_alerts_testing")
resource "discord_text_channel" "yucca_alerts_staging" {
name = "yucca-alerts-staging"
position = index(local.channel_order.yucca, "yucca_alerts_staging")
server_id = discord_server.server.id
category = discord_category_channel.yucca.id
sync_perms_with_category = false
Expand Down
5 changes: 5 additions & 0 deletions tf/deployment/modules/scoped/discord/community/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ provider "onepassword" {
url = var.op_connect_url
token = var.op_connect_token
}

provider "onepassword" {
alias = "futo"
service_account_token = var.futo_op_service_account_token
}
5 changes: 5 additions & 0 deletions tf/deployment/modules/scoped/discord/community/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ variable "op_connect_token" {

variable "discord_token" {}

variable "futo_op_service_account_token" {
description = "1Password service-account token for the FUTO account, used to write the webhook URLs into the yucca/o11y vaults"
sensitive = true
}

variable "discord_server_id" {}

variable "env" {}
Expand Down
55 changes: 55 additions & 0 deletions tf/deployment/modules/scoped/discord/community/webhooks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,61 @@ output "team_alerts_grafana_webhook_url" {
sensitive = true
}

resource "discord_webhook" "yucca_alerts_grafana" {
name = "Grafana"
channel_id = discord_text_channel.yucca_alerts.id
avatar_data_uri = local.image_data_uris["grafana_128_128.webp"]
}

output "yucca_alerts_grafana_webhook_url" {
value = discord_webhook.yucca_alerts_grafana.url
sensitive = true
}

resource "discord_webhook" "yucca_alerts_staging_grafana" {
name = "Grafana Staging"
channel_id = discord_text_channel.yucca_alerts_staging.id
avatar_data_uri = local.image_data_uris["grafana_128_128.webp"]
}

output "yucca_alerts_staging_grafana_webhook_url" {
value = discord_webhook.yucca_alerts_staging_grafana.url
sensitive = true
}

# Publish each cluster's yucca-alerts Grafana webhook URL into its FUTO o11y vault
# (o11y_tf_<env>) so the o11y stack can consume it. The o11y_tf_* vaults live in the
# FUTO 1Password account, which the default (immich Connect) provider cannot reach —
# hence provider = onepassword.futo.
#
# All three yucca-alerts channels live on the community server, which only the prod
# discord apply manages — the dev apply targets the test server and would clobber the
# vault items with test-server URLs on every run (its service account may not have o11y
# vault access either, and data sources execute during every plan). Hence the for_each
# collapses to an empty map outside prod.
locals {
o11y_grafana_discord_webhooks = {
prod = discord_webhook.yucca_alerts_grafana.url
staging = discord_webhook.yucca_alerts_staging_grafana.url
dev = discord_webhook.yucca_alerts_dev_grafana.url
}
}

data "onepassword_vault" "o11y_tf" {
for_each = { for env, url in local.o11y_grafana_discord_webhooks : env => url if var.env == "prod" }
provider = onepassword.futo
name = "o11y_tf_${each.key}"
}

resource "onepassword_item" "o11y_grafana_discord_webhook" {
for_each = { for env, url in local.o11y_grafana_discord_webhooks : env => url if var.env == "prod" }
provider = onepassword.futo
vault = data.onepassword_vault.o11y_tf[each.key].uuid
title = "GRAFANA_DISCORD_WEBHOOK"
category = "password"
password = each.value
}

resource "discord_webhook" "yucca_alerts_dev_grafana" {
name = "Grafana Dev"
channel_id = discord_text_channel.yucca_alerts_dev.id
Expand Down
Loading