What would be a best-practice to pass the same attributes/parameters to multiple blocks? I find myself always duplicating code because of this:
env = var.env
location = var.location
tags = local.tags
rg_name = var.rg_name
subscription_id = var.subscription_id
service_plan_id = local.service_plan_id
nodejs_version = var.nodejs_version
Here is a sample of what I currently use:
// development front-end NUXT APP dev
module "nuxt-app" {
source = "./nuxt-app"
env = var.env
name = "appweb-${var.env}-001"
app_service_name = "appweb-${var.env}-001"
location = var.location
tags = local.tags
rg_name = var.rg_name
subscription_id = var.subscription_id
service_plan_id = local.service_plan_id
nodejs_version = var.nodejs_version
}
module "nuxt-app-slot" {
source = "./nuxt-app-slot"
//skip this resource for non-dev environments
count = local.prod_only
env = var.env
name = "preview"
app_service_name = "appweb-${var.env}-001"
location = var.location
tags = local.tags
rg_name = var.rg_name
subscription_id = var.subscription_id
service_plan_id = local.service_plan_id
nodejs_version = var.nodejs_version
}
My target would be:
// development front-end NUXT APP dev
module "nuxt-app" {
source = "./nuxt-app"
name = "appweb-${var.env}-001"
app_service_name = "appweb-${var.env}-001"
...add somehow attributes
}
module "nuxt-app-slot" {
source = "./nuxt-app-slot"
//skip this resource for non-dev environments
count = local.prod_only
name = "preview"
app_service_name = "appweb-${var.env}-001"
...add somehow attributes
}