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
2
votes
1 answer

How can I pass a comma separated array to a resource in terraform v0.12.0?

In the following code block I'm trying to pass an array of server names to the attributes_json block: resource "aws_instance" "consul-server" { ami = var.consul-server instance_type = "t2.nano" key_name = var.aws_key_name …
TyMac
  • 783
  • 2
  • 9
  • 32
2
votes
1 answer

How to prepare rendered JSON for aws-cli in Terraform?

In another thread I have asked how to keep ECS task definitions active in AWS. As a result I am planning to update a task definition like this: resource "null_resource" "update_task_definition" { triggers { keys = "${uuid()}" } #…
bitbrain
  • 603
  • 5
  • 12
2
votes
0 answers

How to manipulate HCL abstract syntax tree?

I'm writing a compiler using HCL (HashiCorp Configuration Language) and I'm trying to manipulate the AST so that I can add my custom logic. hclParseTree, err := hcl.Parse(input) check(err) spew.Dump(hclParseTree) I've only managed to print all the…
Paul Razvan Berg
  • 16,949
  • 9
  • 76
  • 114
2
votes
1 answer

Append string to the map type in Terraform

I have a next expression in Terraform (v0.11.7): my_expression = "${zipmap(random_shuffle.x.result, random_shuffle.x.result)}" I need to append string to right expression, e.g: my_expression = "${zipmap(random_shuffle.x.result, "*" +…
goldver
  • 191
  • 1
  • 12
2
votes
0 answers

Searching and updating HCL for strings in Go

Hey guys I ran into a road block trying to figure out how to search all our service/policy_names to ensure that they have certain capabilities. Lets say I have a vault policy like the following bash-4.4$ vault policy read service/admin # Token…
ehime
  • 8,025
  • 14
  • 51
  • 110
2
votes
1 answer

How to parse each HCL dictionary item by golang?

I have tried to parse HCL config using golang, but it's not working. type cfg_dict struct { name string `hcl:",key"` type string `hcl:"type"` } type hcl_config struct { config_items cfg_dict …
cdevman
  • 119
  • 2
  • 14
2
votes
2 answers

Managing granular network acl's with terraform

I'm doing a proof-of-concept work with terraform to move our infrastructure code to it. It's my second day and I feel like I'm doing something extremely wrong or missing some points while trying to setup network ACL's because the code became very…
Muhammet Can
  • 1,304
  • 2
  • 16
  • 30
2
votes
1 answer

how to escape double quotation in terraform?

I am using the remote-exec provider in my terraform v0.9.11 template like this: ... provisioner "remote-exec" { inline = [ "Set-ExecutionPolicy Bypass -force", …
Sami
  • 7,797
  • 18
  • 45
  • 69
1
vote
1 answer

How to apply tag to Cloud Posse TF lambda-function module's child resource

In TF Cloud I define an AWS Lambda like so module "lambda-function" { source = "cloudposse/lambda-function/aws" version = "0.5.1" environment = var.environment function_name = "${local.service_name}-${var.environment}-restart" …
1
vote
0 answers

Dynamically execute dependency blocks in terragrunt with for_each (or similar)

I'm trying to DRY/parametrize the dependency block of my terragrunt file for my multi-environments setup. I've these dependencies: dependency "development" { config_path = "../../development/mandatory_resources" } dependency "production" { …
Gabriele B
  • 2,665
  • 1
  • 25
  • 40
1
vote
2 answers

How to break nomad job spec files into smaller manageable units

I have a job spec file that I am working to improve. It has about 3000 lines of HCL code and is difficult to maintain. I looked on HashiCorp's documentation and not seeing how to break a job spec file into multiple files, i.e, break out the tasks,…
Michael Amos
  • 23
  • 1
  • 5
1
vote
0 answers

Unable to enemurate all disks error in terraform while creating vm vsphere

I tried to create a new VM "TEST" in vsphere using terraform, while specifying the disk I got this error in terraform "Error: error powering on virtual machine: powerOn task for vm "/Datacenter/vm/Test" failed: Unable to enumerate all disks." (Line…
A.Ikram
  • 77
  • 10
1
vote
1 answer

Use S3 Object tag from terraform

I have a split code deploy / infrastructure deploy that I'm working with. I currently have it working by uploading a separate file containing the codes' sha256 code_hash like so: data "archive_file" "source" { type = "zip" source_file =…
Serdalis
  • 10,296
  • 2
  • 38
  • 58
1
vote
1 answer

Terraform loops with both index and values

I'm creating an Openstack LoadBalancer with Terraform and I need to loop through a collection of instances and use at the same time the index. In particular, I have 2 nodes: output "nodes_1" { value = [ for vm in…
sctx
  • 128
  • 2
  • 11
1
vote
1 answer

Terraform how to use for_each for ssh_keys when creating multiple digitalocean droplets

Background I am using the digitalocean_droplet resource. I would like to create multiple digitalocean droplets, each with their own SSH key. The droplets will be created by reading locals variable named droplets at the top of the script for ease of…
Jimbo
  • 25,790
  • 15
  • 86
  • 131