Skip to content

Commit

Permalink
fix(infra): resolve correct cockroachdb remote state (#976)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
NathanFlurry committed Jul 3, 2024
1 parent 088e05e commit 8413349
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion infra/tf/grafana/grafana.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ locals {
}
}

crdb_host = "${try(data.terraform_remote_state.cockroachdb_k8s.outputs.host, data.terraform_remote_state.cockroachdb_managed.outputs.host)}:${try(data.terraform_remote_state.cockroachdb_k8s.outputs.port, data.terraform_remote_state.cockroachdb_managed.outputs.port)}"
crdb_host = "${data.terraform_remote_state.cockroachdb.outputs.host}:${data.terraform_remote_state.cockroachdb.outputs.port}"
}

module "crdb_user_grafana_secrets" {
Expand Down
12 changes: 8 additions & 4 deletions lib/bolt/core/src/dep/terraform/remote_states.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ use std::collections::HashMap;
use derive_builder::Builder;
use maplit::hashmap;

use crate::context::ProjectContext;
use crate::{config, context::ProjectContext};

/// Defines the dependency graph for the Terraform plans.
///
/// This is used to automatically generate `terraform_remote_state` blocks
/// for each Terraform plan with the correct state backend.
pub fn dependency_graph(_ctx: &ProjectContext) -> HashMap<&'static str, Vec<RemoteState>> {
pub fn dependency_graph(ctx: &ProjectContext) -> HashMap<&'static str, Vec<RemoteState>> {
let crdb_plan = match &ctx.ns().cluster.kind {
config::ns::ClusterKind::SingleNode { .. } => "cockroachdb_k8s",
config::ns::ClusterKind::Distributed { .. } => "cockroachdb_managed",
};

hashmap! {
"dns" => vec![
RemoteStateBuilder::default().plan_id("k8s_infra").build().unwrap(),
Expand All @@ -33,8 +38,7 @@ pub fn dependency_graph(_ctx: &ProjectContext) -> HashMap<&'static str, Vec<Remo
RemoteStateBuilder::default().plan_id("dns").build().unwrap(),
],
"grafana" => vec![
RemoteStateBuilder::default().plan_id("cockroachdb_k8s").build().unwrap(),
RemoteStateBuilder::default().plan_id("cockroachdb_managed").build().unwrap(),
RemoteStateBuilder::default().plan_id(crdb_plan).data_name("cockroachdb").build().unwrap(),
],
"opengb" => vec![
RemoteStateBuilder::default().plan_id("dns").build().unwrap(),
Expand Down

0 comments on commit 8413349

Please sign in to comment.