Questions tagged [terraform-loop]

12 questions
0
votes
0 answers

Terraform: String is not interpolated for module provider alias

Terraform version: "1.3.7" Terraform fails with A provider configuration reference must not be given in quotes. error when trying to provide providers to child module being called inside a for loop. The dynamic provider definition is done like…
0
votes
0 answers

Terraform: Can't access each.value.name in for loop

I've seen similar questions here, but nothing that addresses accessing a member. I'm guessing this is something easy and my mind just isn't working. I have a nested for loop that is producing what seems to be the output I need, but when I try to use…
Jonathon Anderson
  • 1,162
  • 1
  • 8
  • 24
0
votes
1 answer

Terraform for_each with condition and key removal

I need to find a way to specify a for_each resource creation where dynamically I use a specific map AND at the same time, remove an item/key or skip an item in that map. I currently us the following for_each to specify which map to use for…
Wolfgang
  • 159
  • 1
  • 7
0
votes
1 answer

Terraform object identification when created via for_each

I have a resource to create subnets like this in azurerm with client_name =["client1","client2"]: resource "azurerm_subnet" "subnets" { for_each = var.subnet_map_large resource_group_name = var.resource_group_name …
Wolfgang
  • 159
  • 1
  • 7
0
votes
2 answers

Terraform: Invalid dynamic for_each value. Cannot use a list of object value in for_each. An iterable collection is required

Terraform version: "1.2.9" Terraform fails with invalid value error when input variable with type list(object({})) and marked as sensitive = true is passed to dynamic block with for_each. The error is not seen when the input variable is marked as…
0
votes
1 answer

Terraform error : An argument named "count" is not expected here

I am trying to loop the container names using count in the Azure Event Hub in Azure Event Hub namespace. however I am getting to below error while terraform plan. Below is the Terraform code resource "azurerm_resource_group" "test-rg" { name =…
0
votes
1 answer

Terraform AWS Lambda function with terraform

I am new to Terraform, I am having difficulty in configuring vpc_config in Lambda function. main.tf resource "aws_lambda_function" "lambda" { function_name = var.function_name s3_bucket = var.s3_bucket_name s3_key = var.s3_key vpc_config…
0
votes
1 answer

Terraform : Invalid dynamic for_each value => Cannot use a set of object value in for_each. An iterable collection is required

In terraform version 1.1.9 am facing the below issue while doing terraform apply. Help me to fix how this for_each can be done without error. rke_nodes values sample will be : # Outputs output "rancher_nodes" {   value = [         for instance in…
0
votes
1 answer

terraform dynamic block for_each construction

Newbie question. This is my variable file instances = ["instance1", "instance2"] cors_rules = { instance1 = { origin = ["https://instance.com", "http://localhost:4200"], }, instance2 = { origin =…
iluv_dev
  • 135
  • 1
  • 11
0
votes
1 answer

Get a list of created resources in terraform

I am creating AWS ECR repositories via terraform resource "aws_ecr_repository" "repo1" { name = "repo1" image_tag_mutability = "MUTABLE" image_scanning_configuration { scan_on_push = true } } resource…
-1
votes
1 answer

Terraform local variable with map

I want to create this metric_info variable using the values of the metric_config variable I tried some ways but without success. The reported error is there below. Maybe bringing the metrics out further like this metric_config = [ + metrics = { and…
-1
votes
2 answers

How to create a dynamic definition for AWS state machine on Terraform?

I'm trying to create a definition for AWS state machine generating it from this list of object: state_object_list = [ { name = "task1", type = "Task", resource = "arn:aws:lambda:us-east-1:123456789:function:test", end =…