diff --git a/CN_PREPROD/alerting/providers.tf b/CN_PREPROD/alerting/providers.tf index 1ea5c016..10270697 100644 --- a/CN_PREPROD/alerting/providers.tf +++ b/CN_PREPROD/alerting/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/CN_PREPROD/dashboard/providers.tf b/CN_PREPROD/dashboard/providers.tf index 1ea5c016..10270697 100644 --- a/CN_PREPROD/dashboard/providers.tf +++ b/CN_PREPROD/dashboard/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/CN_PREPROD/main.tf b/CN_PREPROD/main.tf index 5815bf46..604c0a21 100644 --- a/CN_PREPROD/main.tf +++ b/CN_PREPROD/main.tf @@ -1,12 +1,20 @@ module "management_zone" { source = "./management_zone" } - module "alerting" { source = "./alerting" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } module "dashboard" { source = "./dashboard" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } +module "custom_service" { + source = "./custom_service" +} +module "processgroup_naming" { + source = "./processgroup_naming" +} +module "service_naming" { + source = "./service_naming" +} \ No newline at end of file diff --git a/CN_PROD/alerting/providers.tf b/CN_PROD/alerting/providers.tf index 1ea5c016..10270697 100644 --- a/CN_PROD/alerting/providers.tf +++ b/CN_PROD/alerting/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/CN_PROD/dashboard/providers.tf b/CN_PROD/dashboard/providers.tf index 1ea5c016..10270697 100644 --- a/CN_PROD/dashboard/providers.tf +++ b/CN_PROD/dashboard/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/CN_PROD/main.tf b/CN_PROD/main.tf index 5815bf46..604c0a21 100644 --- a/CN_PROD/main.tf +++ b/CN_PROD/main.tf @@ -1,12 +1,20 @@ module "management_zone" { source = "./management_zone" } - module "alerting" { source = "./alerting" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } module "dashboard" { source = "./dashboard" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } +module "custom_service" { + source = "./custom_service" +} +module "processgroup_naming" { + source = "./processgroup_naming" +} +module "service_naming" { + source = "./service_naming" +} \ No newline at end of file diff --git a/EMEA_PREPROD/alerting/providers.tf b/EMEA_PREPROD/alerting/providers.tf index 1ea5c016..10270697 100644 --- a/EMEA_PREPROD/alerting/providers.tf +++ b/EMEA_PREPROD/alerting/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/EMEA_PREPROD/dashboard/providers.tf b/EMEA_PREPROD/dashboard/providers.tf index 1ea5c016..10270697 100644 --- a/EMEA_PREPROD/dashboard/providers.tf +++ b/EMEA_PREPROD/dashboard/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/EMEA_PREPROD/main.tf b/EMEA_PREPROD/main.tf index 5815bf46..604c0a21 100644 --- a/EMEA_PREPROD/main.tf +++ b/EMEA_PREPROD/main.tf @@ -1,12 +1,20 @@ module "management_zone" { source = "./management_zone" } - module "alerting" { source = "./alerting" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } module "dashboard" { source = "./dashboard" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } +module "custom_service" { + source = "./custom_service" +} +module "processgroup_naming" { + source = "./processgroup_naming" +} +module "service_naming" { + source = "./service_naming" +} \ No newline at end of file diff --git a/EMEA_PROD/alerting/providers.tf b/EMEA_PROD/alerting/providers.tf index 1ea5c016..10270697 100644 --- a/EMEA_PROD/alerting/providers.tf +++ b/EMEA_PROD/alerting/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/EMEA_PROD/dashboard/providers.tf b/EMEA_PROD/dashboard/providers.tf index 1ea5c016..10270697 100644 --- a/EMEA_PROD/dashboard/providers.tf +++ b/EMEA_PROD/dashboard/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/EMEA_PROD/main.tf b/EMEA_PROD/main.tf index 5815bf46..604c0a21 100644 --- a/EMEA_PROD/main.tf +++ b/EMEA_PROD/main.tf @@ -1,12 +1,20 @@ module "management_zone" { source = "./management_zone" } - module "alerting" { source = "./alerting" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } module "dashboard" { source = "./dashboard" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } +module "custom_service" { + source = "./custom_service" +} +module "processgroup_naming" { + source = "./processgroup_naming" +} +module "service_naming" { + source = "./service_naming" +} \ No newline at end of file diff --git a/NA_PREPROD/alerting/providers.tf b/NA_PREPROD/alerting/providers.tf index 1ea5c016..10270697 100644 --- a/NA_PREPROD/alerting/providers.tf +++ b/NA_PREPROD/alerting/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/NA_PREPROD/dashboard/providers.tf b/NA_PREPROD/dashboard/providers.tf index 1ea5c016..10270697 100644 --- a/NA_PREPROD/dashboard/providers.tf +++ b/NA_PREPROD/dashboard/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/NA_PREPROD/main.tf b/NA_PREPROD/main.tf index 5815bf46..604c0a21 100644 --- a/NA_PREPROD/main.tf +++ b/NA_PREPROD/main.tf @@ -1,12 +1,20 @@ module "management_zone" { source = "./management_zone" } - module "alerting" { source = "./alerting" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } module "dashboard" { source = "./dashboard" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } +module "custom_service" { + source = "./custom_service" +} +module "processgroup_naming" { + source = "./processgroup_naming" +} +module "service_naming" { + source = "./service_naming" +} \ No newline at end of file diff --git a/NA_PROD/alerting/providers.tf b/NA_PROD/alerting/providers.tf index 1ea5c016..10270697 100644 --- a/NA_PROD/alerting/providers.tf +++ b/NA_PROD/alerting/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/NA_PROD/dashboard/providers.tf b/NA_PROD/dashboard/providers.tf index 1ea5c016..10270697 100644 --- a/NA_PROD/dashboard/providers.tf +++ b/NA_PROD/dashboard/providers.tf @@ -5,7 +5,4 @@ terraform { source = "dynatrace-oss/dynatrace" } } -} -variable "mzid" { - type = string } \ No newline at end of file diff --git a/NA_PROD/main.tf b/NA_PROD/main.tf index 5815bf46..604c0a21 100644 --- a/NA_PROD/main.tf +++ b/NA_PROD/main.tf @@ -1,12 +1,20 @@ module "management_zone" { source = "./management_zone" } - module "alerting" { source = "./alerting" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } module "dashboard" { source = "./dashboard" - mzid = "${module.management_zone.mzid}" + depends_on = [module.management_zone] } +module "custom_service" { + source = "./custom_service" +} +module "processgroup_naming" { + source = "./processgroup_naming" +} +module "service_naming" { + source = "./service_naming" +} \ No newline at end of file diff --git a/_templates/_template_alerting.tf b/_templates/_template_alerting.tf index 470d52e6..2c08a7e7 100644 --- a/_templates/_template_alerting.tf +++ b/_templates/_template_alerting.tf @@ -1,6 +1,6 @@ resource "dynatrace_alerting" "_" { name = " " - management_zone = var.mzid + management_zone = data.dynatrace_management_zone..id rules { rule { delay_in_minutes = 0 diff --git a/_templates/_template_dashboard.tf b/_templates/_template_dashboard.tf index c357db4a..4a3246c7 100644 --- a/_templates/_template_dashboard.tf +++ b/_templates/_template_dashboard.tf @@ -22,7 +22,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } filter_config { @@ -87,7 +87,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } } @@ -104,7 +104,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } } @@ -136,7 +136,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } filter_config { @@ -231,7 +231,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } filter_config { @@ -267,7 +267,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } filter_config { @@ -303,7 +303,7 @@ resource "dynatrace_dashboard" "_" { filter { management_zone { name = "" - id = var.mzid + id = data.dynatrace_management_zone..id } } filter_config { diff --git a/_templates/_template_management_zone.tf b/_templates/_template_management_zone.tf index 946f5ad2..dddb3634 100644 --- a/_templates/_template_management_zone.tf +++ b/_templates/_template_management_zone.tf @@ -16,7 +16,4 @@ resource "dynatrace_management_zone" "" { enabled = true selector = "type(SERVICE),databaseName.exists(),toRelationship.calls(type(SERVICE),tag(\"compass-id:\"))" } -} -output "mzid" { - value = "${dynatrace_management_zone..id}" } \ No newline at end of file diff --git a/onboarding.py b/onboarding.py index 85ab0135..7778ddfb 100644 --- a/onboarding.py +++ b/onboarding.py @@ -33,6 +33,9 @@ def main(slo_path): #print('./'+item+'/'+configoption+'/'+args.appname+'.tf') with open('./'+item+'/'+configoption+'/'+args.appname+'.tf', 'w') as file: file.write(data) + datastring = "data \"dynatrace_management_zone\" \""+args.appname+"\"{ name=\""+args.appname+"\" }\n" + with open('./'+item+'/'+configoption+'/data_source.tf', 'a') as file: + file.write(datastring) for envconfigoption in envconfigoptions: for env in envs.get("environments"): with open('./_templates/_template_'+envconfigoption+'.tf') as file: @@ -43,6 +46,8 @@ def main(slo_path): #print('./'+item+'/'+envconfigoption+'/'+args.appname+'_'+env+'.tf') with open('./'+item+'/'+envconfigoption+'/'+args.appname+'_'+env+'.tf', 'w') as file: file.write(data) + with open('./'+item+'/'+envconfigoption+'/data_source.tf', 'a') as file: + file.write(datastring) else: print("ERROR: No appname/compassid specified")