Questions tagged [hcl]

HashiCorp Configuration Language. The structured configuration syntax that serves as the basis for Terraform's configuration language.

HCL establishes the syntax Terraform uses for things like arguments, blocks, literal values, and expressions. But what most people think of as the Terraform language extends beyond just the syntax; the built-in functions, Terraform-specific block types (like resource and variable), and Terraform-specific named values available in expressions are all implementation details of Terraform itself.

Source: https://www.terraform.io/docs/glossary.html#hcl

291 questions
1
vote
1 answer

What does a ternary inside a for_each loop in a dynamic-block do?

In the following example enable_aggregate_limit is of type: bool. From what I understand it will render the parameter argument with content if its value is TRUE and it does not create the parameter if its FALSE. What does the ["yes"] and [] mean…
Hedge
  • 16,142
  • 42
  • 141
  • 246
1
vote
1 answer

dynamic path through json loaded in terraform

I’m loading a json file with jsondecode() in terraform, and I need to dynamically lookup a path in the json tree. Eg say I have the following json in file.json: { "some1": { "path1": { "key1": value1 "key2": value2 } …
Oliver
  • 27,510
  • 9
  • 72
  • 103
1
vote
1 answer

TF: Loop through map with lookup and set variable accordingly

I have a map with some environment ID's as the key, then keywords as the values in a list. variable "environments" { type = map(list(string)) default = { "env-one" = ["dev", "test", "stage", "staging"], "env-two" = ["prod",…
jonnybinthemix
  • 637
  • 1
  • 9
  • 29
1
vote
2 answers

How to run TFLint Docker - Passing multiple Args

Running TFLint through their Docker Image Here - I have to pass tflint multiple commands one after the other to initialize and run the tool which is where I'm running into issues I have ran it locally using the following commands, which returns what…
ASHR
  • 23
  • 5
1
vote
2 answers

Howto uniquely claim an element from a list in terraform?

I'm looking for a way to uniquely assign an element from a list to a resource in terraform. I find it hard to explain so I hope the following explains what I want to achieve: main.tf locals { networks = toset(["foo", "bar", "baz"]) …
1
vote
1 answer

print terraform output from list of list to a list of strings

I am working with vm deployments over AWS with terraform(v1.0.9) as infrastructure as code. i have Terraform output.tf to print two lan a ips and code prints, list of lists like [["ip_a",],["ip_b",]] but i want a list like this ["ip_a",…
1
vote
0 answers

How to properly encode null values inside jsonencode() blocks in Terraform for aws_cloudformation_stack resource?

There is a bug in the current version of the official aws_elasticsearch_domain resource which prevents you from creating new OpenSearch domains (and also changing existing domains). To circumvent this, I'm working on a module that creates an…
1
vote
1 answer

Unable to reference an AWS API Gateway Usage Plan as a data source in Terraform

I have two Terraform projects that are deployed at different times. One of them needs to reference an API Gateway Usage plan in the other project, which should be deployed first. The code looks like this: data "aws_api_gateway_usage_plan"…
Michael
  • 913
  • 3
  • 10
  • 18
1
vote
2 answers

terraform temporary/intermediate variables in loops?

I would like to know if it is possible to use temporary variables inside a for loop for intermediate computation. If yes, what is the syntax to use that, the example is simplified just to illustrate the problem. This example code works. I've…
xbalaji
  • 982
  • 7
  • 16
1
vote
1 answer

Creating resources in terraform in Azure using existing resource and creating new one

I am having difficulty in creating resources in azure using terraform Vnet is already present and it is in rg group Resource group is present and vnet is in that group I am creating 1 subnets new resources in another existing resource group name…
1
vote
1 answer

Creating multiple SecurityGroups / Rules in AWS using Terraform

I am trying to create multiple Security Groups and rules within this group at the same time in a module for AWS. I have a variable type like this below variable "security_rules" { type = map(map(object({ type = string …
1
vote
2 answers

Have optional sub-variables in required Terraform variable

I have created a module corresponding to the Azure Firewall Network Rule Collection. The module looks like this: resource "azurerm_firewall_network_rule_collection" "fwnrc" { name = "fwnrc-${var.name}" resource_group_name =…
GLaDER
  • 345
  • 2
  • 17
1
vote
2 answers

Terraform github_repository 401 in module but works in main scope

I have a github provider declared with a personal access token. Trying to create a repository like the following works: resource "github_repository" "test" { name = "test" visibility = "private" } However, I want to create something reusable.…
JSON Brody
  • 736
  • 1
  • 4
  • 23
1
vote
1 answer

Combining usage of Terraform's zipmap, maps, and lists

I have two different scenarios, one with public subnets and one with private. For both, I would like to apply some combination of for-loop and zipmask to have a single map object. You can assume I have checked the ordering of the two input…
d8aninja
  • 3,233
  • 4
  • 36
  • 60
1
vote
1 answer

Create dynamic block in terraform

I wanted to create google_compute_health_check in terraform and I'm thinking about how to make them the most versatile. My code atm looks like that application.hcl inputs = { health_checks = { tcp-health-check = { name =…
CptDolphin
  • 404
  • 7
  • 23