terraform0.12+

Dynamic block with for_each inside a resource created with a for_each

江枫思渺然 提交于 2021-02-07 10:00:21
问题 I am trying to build multiple vnets in Azure using Terraform 0.12+ and its new for_each and running into some trouble. I was hoping that the new capabilities would allow me to create a generic network module that takes in a complex variable but I perhaps have reached its limit or am just not thinking it through correctly.. Essentially I my variable is built like variable "networks" { type = list(object({ name = string, newbits = number, netnum = number, subnets = list(object({ name = string,

Dynamic block with for_each inside a resource created with a for_each

人盡茶涼 提交于 2021-02-07 10:00:03
问题 I am trying to build multiple vnets in Azure using Terraform 0.12+ and its new for_each and running into some trouble. I was hoping that the new capabilities would allow me to create a generic network module that takes in a complex variable but I perhaps have reached its limit or am just not thinking it through correctly.. Essentially I my variable is built like variable "networks" { type = list(object({ name = string, newbits = number, netnum = number, subnets = list(object({ name = string,

Terraform - access root module script from child module

限于喜欢 提交于 2021-01-29 04:04:42
问题 I have a ROOT_MODULE with main.tf : #Root Module - Just run the script resource "null_resource" "example" { provisioner "local_exec" { command = "./script.sh" } and script.sh : echo "Hello world now I have another directory elsewhere where I've created a CHILD_MODULE with another main.tf : #Child Module module "ROOT_MODULE" { source = "gitlabURL/ROOT_MODULE" } I've exported my planfile: terraform plan -out="planfile" however, when I do terraform apply against the planfile, the directory I am

Use a map of lists of maps in resource creation

眉间皱痕 提交于 2021-01-28 05:05:13
问题 I want to be able to create multiple R53 records, using the following format defined in TF Vars: custom_zone_records = { "demo.a.com" = [ {"*.b" = {type: "CNAME", records: ["d.com"]}}, {"*.c" = {type: "CNAME", records: ["d.com"]}} ] } Using the record as an example, it should create the R53 record of: Name: *.b.demo.a.com Type: CNAME Records: ["d.com"] The input variable is defined as: variable "custom_zone_records" { description = "A map of maps for custom zone records" type = map(list(map

Use a map of lists of maps in resource creation

ⅰ亾dé卋堺 提交于 2021-01-28 05:03:49
问题 I want to be able to create multiple R53 records, using the following format defined in TF Vars: custom_zone_records = { "demo.a.com" = [ {"*.b" = {type: "CNAME", records: ["d.com"]}}, {"*.c" = {type: "CNAME", records: ["d.com"]}} ] } Using the record as an example, it should create the R53 record of: Name: *.b.demo.a.com Type: CNAME Records: ["d.com"] The input variable is defined as: variable "custom_zone_records" { description = "A map of maps for custom zone records" type = map(list(map

How to correctly use each.value in for_each in terraform?

二次信任 提交于 2021-01-05 07:23:44
问题 I am trying to create a files for each user with the projects assigned to them as content of the file. I amunable to get the "${each.value}" as it is a list of strings. Any way around this please? locals { data = { "project1" = { user_assigned = ["user1", "user2", "user3"] } "project2" = { user_assigned = ["user2", "user3", "user4"] } } ` resource "local_file" "foo" { for_each = transpose(zipmap(keys(local.data), values(local.data)[*].user_assigned)) content = "${each.value}" filename = "$

Terraform (0.12.29) import not working as expected; import succeeded but plan shows destroy & recreate

不想你离开。 提交于 2020-12-13 03:30:30
问题 Some Background: We have terraform code to create various AWS resources. Some of these resources are created per AWS account and hence are structured to be stored in a account-scope folder in our project. This was when we were only having one AWS region. Now our application is made multi-region and hence these resources are to be created per region for each AWS account. In order to do that we have now moved these TF scripts to region-scope folder which will be run per region. Since these

Terraform (0.12.29) import not working as expected; import succeeded but plan shows destroy & recreate

孤街浪徒 提交于 2020-12-13 03:27:47
问题 Some Background: We have terraform code to create various AWS resources. Some of these resources are created per AWS account and hence are structured to be stored in a account-scope folder in our project. This was when we were only having one AWS region. Now our application is made multi-region and hence these resources are to be created per region for each AWS account. In order to do that we have now moved these TF scripts to region-scope folder which will be run per region. Since these

Terraform (0.12.29) import not working as expected; import succeeded but plan shows destroy & recreate

ぃ、小莉子 提交于 2020-12-13 03:26:15
问题 Some Background: We have terraform code to create various AWS resources. Some of these resources are created per AWS account and hence are structured to be stored in a account-scope folder in our project. This was when we were only having one AWS region. Now our application is made multi-region and hence these resources are to be created per region for each AWS account. In order to do that we have now moved these TF scripts to region-scope folder which will be run per region. Since these