diff --git a/infrastructure/README.md b/infrastructure/README.md index 39dda77fb2..b588a0f517 100644 --- a/infrastructure/README.md +++ b/infrastructure/README.md @@ -6,22 +6,6 @@ - Terraform + Terragrunt - Kubectl -## Geo data seeding - -For both scenarios, be sure to set the corresponding variable back to `false` and run `terragrunt apply` to destroy -the import servers, which are powerful and expensive. - -### For production or staging - -- On the `kubernetes` TF project, set `load_fresh_data_staging` or `load_fresh_data_prod` to true -- Run `terragrunt apply` - -### For other envs - -- On the `kubernetes` TF project, set `load_fresh_data` to true on the nested value inside the `environments` variable. - See the `enviorment` module definition in the root `main.tf` file for info - look into the `for_each` default value. -- Run `terragrunt apply` - ## Deploying new environments The infrastructure is deployed using Terraform, and set up in a way that makes it very easy to deploy new, independent @@ -73,3 +57,9 @@ The `value` in the key-value pair is an object with a set of properties, all of as part of the initial data import process. Defaults to `["seed-data"]` - `image_tag`: tag of the different docker images to pull from the container registry. Does not apply to the Redis image. Defaults to the same value as `key`. + +### Handling production and staging + +The production and staging environments are always deployed, even if they are not declared in the `environments` variable. +However, if you'd like to customize their behavior (for example, reload fresh data), you can explicitly add them to the +`environments` variable, and specify your custom values for each configuration, as you would for any other env. diff --git a/infrastructure/kubernetes/main.tf b/infrastructure/kubernetes/main.tf index 64e73bd003..f7f853d226 100644 --- a/infrastructure/kubernetes/main.tf +++ b/infrastructure/kubernetes/main.tf @@ -9,7 +9,7 @@ terraform { data "terraform_remote_state" "core" { backend = "s3" - config = { + config = { bucket = var.tf_state_bucket region = var.aws_region key = "core.tfstate" @@ -36,18 +36,16 @@ resource "github_actions_secret" "mapbox_api_token_secret" { module "environment" { for_each = merge(var.environments, { - staging = { - load_fresh_data = var.load_fresh_data_staging - data_import_arguments = var.data_import_arguments_staging + staging = merge({ + load_fresh_data = false + data_import_arguments = ["seed-data"] image_tag = "staging" - api_env_vars = lookup(lookup(var.environments, "staging", {}), "api_env_vars", []) - }, - production = { - load_fresh_data = var.load_fresh_data_prod - data_import_arguments = var.data_import_arguments_prod + }, lookup(var.environments, "staging", {})), + production = merge({ + load_fresh_data = false + data_import_arguments = ["seed-data"] image_tag = "main" - api_env_vars = lookup(lookup(var.environments, "production", {}), "api_env_vars", []) - } + }, lookup(var.environments, "production", {})), }) source = "./modules/env" diff --git a/infrastructure/kubernetes/variables.tf b/infrastructure/kubernetes/variables.tf index a05a005c27..52576b52b2 100644 --- a/infrastructure/kubernetes/variables.tf +++ b/infrastructure/kubernetes/variables.tf @@ -50,30 +50,6 @@ variable "environments" { description = "A list of environments" } -variable "load_fresh_data_staging" { - type = bool - default = false - description = "If a new data import should be triggered for the staging app. Clears the current database." -} - -variable "load_fresh_data_prod" { - type = bool - default = false - description = "If a new data import should be triggered for the production app. Clears the current database." -} - -variable "data_import_arguments_prod" { - type = list(string) - default = ["seed-data"] - description = "Arguments to pass to the initial data import process for the production cluster" -} - -variable "data_import_arguments_staging" { - type = list(string) - default = ["seed-data"] - description = "Arguments to pass to the initial data import process for the staging cluster" -} - variable "data_s3_access_key" { type = string sensitive = true diff --git a/infrastructure/kubernetes/vars/terraform.tfvars b/infrastructure/kubernetes/vars/terraform.tfvars index 605877803a..8b1dd83c0e 100644 --- a/infrastructure/kubernetes/vars/terraform.tfvars +++ b/infrastructure/kubernetes/vars/terraform.tfvars @@ -1,17 +1,13 @@ -tf_state_bucket = "landgriffon-tf-state" -environment = "dev" -allowed_account_id = "622152552144" -domain = "landgriffon.com" -load_fresh_data_staging = false -load_fresh_data_prod = false -data_import_arguments_prod = ["seed-data"] -data_import_arguments_staging = ["seed-data"] -repo_name = "landgriffon" +tf_state_bucket = "landgriffon-tf-state" +environment = "dev" +allowed_account_id = "622152552144" +domain = "landgriffon.com" +repo_name = "landgriffon" environments = { dev : {}, test : {}, vcf : {}, tetrapack : {}, - demo: {} + demo : {} }