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
0 answers

Evaluating an hcl.Expression which expected value is a Go interface

I am writing a HCL-based configuration language where some types of blocks can reference other blocks using expressions, as follows: source "my_source" { // some blocks and attributes... to = destination.my_kafka_topic } destination "kafka"…
Antoine Cotten
  • 2,673
  • 18
  • 37
1
vote
2 answers

Terraform assign variable to a lit block

I use the aws provider. For each security group I specify same rule for ssh. How to extract it to a variable and assign to aws_security_group.ingress list? What do I expect: variable "ssh_ingress" { default = { from_port = 22 protocol =…
Belenot
  • 248
  • 1
  • 3
  • 10
1
vote
0 answers

How to update a terraform file from java

I have a terraform script something like below. resource "aws_sfn_state_machine" "sfn_state_machine" { name = "my-state-machine" role_arn = aws_iam_role.iam_for_sfn.arn definition = <
anij
  • 1,322
  • 5
  • 23
  • 39
1
vote
1 answer

Terraform loop over nested object

Let's say I have the following local local: locals { domains = [ "site01.example.com", "site02.example.com", ] } For each domain a certificate is being created, which returns DNS validation options: resource "aws_acm_certificate"…
Nikita Zernov
  • 5,465
  • 6
  • 39
  • 70
1
vote
1 answer

Use local value in variables.tf

How to use local value in variables.tf? I need to assign dynamically value to threshold for two of netapp volume metric alert and I get an error: Error: Variables not allowed. Each NetApp Volume has different storage quota in GB, that's why it needs…
Bater55
  • 73
  • 1
  • 9
1
vote
1 answer

How to loop through a list of s3 buckets and create and attach a number of policies for each bucket?

I am learning about terraform modules and my objective is to build module which takes in a collection of s3 Buckets, and then creates and applies to them some iam policies. What I have tried so far was to have some sort of a for loop, where I…
alt-f4
  • 2,112
  • 17
  • 49
1
vote
1 answer

How to convert hcl tf file to json

want to read TF files with an node app. Therefore I want to read and parse hcl variable declarations. Is there any way to convert a .tf file to a .tf.json file via terraform cli? I‘ve tried terraform show -json, but this outputs my state without…
Gerrit
  • 2,515
  • 5
  • 38
  • 63
1
vote
2 answers

Specify depends_on for dynamic resources created by third party module

I'm using a Terraform handy module published by Google Cloud Platform to spin up a BigQuery dataset complete with several tables and a number of views. This works really well, except that when the views depend on the tables, I have to retry my…
Jay Carlton
  • 1,118
  • 1
  • 11
  • 27
1
vote
2 answers

Terraform - transform list of lists to into a new list of lists

In Terraform, I need to transform my input data structure from e.g.: vip_lists = [ ["1.0.1.1", "1.0.1.2", "1.0.1.3", "1.0.1.4"] ["1.0.2.1", "1.0.2.2", "1.0.2.3", "1.0.2.4"] ["1.0.0.1", "1.0.0.2", "1.0.0.3", "1.0.0.4"] ] to produce an…
Neil Craig
  • 13
  • 5
1
vote
1 answer

How to name resources dynamically based on the env they are in?

I'm trying to unify naming of resources, depending on the environment (dev, stage or prod). I will illustrate with an example. Let's say I want to create an aws iam user resource like: resource "aws_iam_user" "iam_foo" { name = "foo_dev" } Here I…
alt-f4
  • 2,112
  • 17
  • 49
1
vote
1 answer

Use for_each to fill in list argument

I'm trying to add entries to the labels and metadata sub-blocks on the google_monitoring_metric_descriptor resource. I'm having a tough time making for_each loop over my map of structures for each metric descriptor, as well as the inner collections…
Jay Carlton
  • 1,118
  • 1
  • 11
  • 27
1
vote
1 answer

Terraform: output from multiple module calls

Pseudo-code: module "foo-1" { source="./foo" input=1 } module "foo-2" { source="./foo" input=2 } module "foo-3" source="./foo" input=3 } ...etc... (The module ./foo outputs a unique id based on the input value) Problem: I…
Brett Monroe
  • 151
  • 1
  • 7
1
vote
1 answer

target_groups optional param is not optional : terraform

Error: Invalid index on .terraform/modules/database-security-group/main.tf line 70, in resource "aws_security_group_rule" "ingress_rules": 70: to_port = var.rules[var.ingress_rules[count.index]][1] |---------------- | count.index is…
loanshark
  • 105
  • 2
  • 8
1
vote
3 answers

What is the purpose of an import in Terraform?

This question is not how to import and it's not what's the purpose of tfstate. It's what's the purpose of importing a pre-existing resource, esp. compared to just referencing the ID of the existing resource? Terraform has the feature of terraform…
Yann Stoneman
  • 953
  • 11
  • 35
1
vote
1 answer

Terraform 12. Dynamically generate block

I have next list: local { ... step_scaling_out_policy_configuration = { "adjustment_type" = "ChangeInCapacity" "cooldown" = 300 "metric_aggregation_type" = "Maximum" "step_adjustment" = { …
ipeacocks
  • 2,187
  • 3
  • 32
  • 47