Skip to content

Commit

Permalink
Figure out env from dir
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Aug 16, 2024
1 parent a2eb4b1 commit b59934a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
26 changes: 7 additions & 19 deletions deployment/live/example-gcp/ci/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,15 @@ terraform {
source = "${get_repo_root()}/deployment/modules/example-gcp"
}

locals {
project_id = get_env("GOOGLE_PROJECT", "trillian-tessera")
location = get_env("GOOGLE_REGION", "us-central1")
base_name = get_env("TESSERA_BASE_NAME", "example-gcp")
include "root" {
path = find_in_parent_folders()
expose = true
}

inputs = merge(
local,
{}
include.root.locals,
{
example_docker_image = "todo"
}
)

remote_state {
backend = "gcs"

config = {
project = local.project_id
location = local.location
bucket = "${local.project_id}-${local.base_name}-terraform-state"

gcs_bucket_labels = {
name = "terraform_state_storage"
}
}
}
25 changes: 25 additions & 0 deletions deployment/live/example-gcp/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
terraform {
source = "${get_repo_root()}/deployment/modules/example-gcp"
}

locals {
project_id = get_env("GOOGLE_PROJECT", "trillian-tessera")
location = get_env("GOOGLE_REGION", "us-central1")
base_name = get_env("TESSERA_BASE_NAME", "example-gcp")
env = path_relative_to_include()
}

remote_state {
backend = "gcs"

config = {
project = local.project_id
location = local.location
bucket = "${local.project_id}-${local.base_name}-${local.env}-terraform-state"
prefix = "${path_relative_to_include()}/terraform.tfstate"

gcs_bucket_labels = {
name = "terraform_state_storage"
}
}
}
5 changes: 3 additions & 2 deletions deployment/modules/example-gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ terraform {
backend "gcs" {}
}

module "infra" {
source = "../../../modules/gcp"
module "gcp" {
source = "../../../modules"

project_id = var.project_id
base_name = var.base_name
location = var.location
env = var.env
}

###
Expand Down

0 comments on commit b59934a

Please sign in to comment.