Skip to content
Plugins (190)

terraform

stable

A Terraform HCL code generator that produces resource, variable, output, provider, module, and backend blocks as strings for use in infrastructure-as-code workflows.

use plugin terraform
14 functions Cloud
Runs with the native Zolo host

Plugin snippets can be edited in the Playground, but native capabilities are executed locally with the Zolo CLI.

/ filter jk navigate Esc clear
Functions (14)
  1. build_resource Generate a resource block
  2. build_variable Generate a variable block
  3. build_output Generate an output block
  4. build_provider Generate a provider block
  5. build_data Generate a data source block
  6. build_locals Generate a locals block
  7. build_module Generate a module block
  8. build_terraform Generate a terraform required_providers block
  9. build_backend Generate a terraform backend block
  10. build_provisioner Generate a provisioner block
  11. concat_blocks Join multiple HCL blocks into one string
  12. hcl_string Wrap a value as a quoted HCL string
  13. hcl_list Render a table as an HCL list literal
  14. hcl_map Render a table as an HCL map literal

From import to result

  1. 01Import only what you use
  2. 02Copy the smallest example
  3. 03Run it with the Zolo CLI

Generate a resource block

Generates a resource block. attrs is a table of attribute key-value pairs. Nested tables become nested blocks.

use plugin terraform::{terraform}

let block = terraform.build_resource("aws_s3_bucket", "my_bucket", #{"bucket": "my-app-bucket", "force_destroy": true})
print(block)
use plugin terraform::{terraform}

let vpc = terraform.build_resource("aws_vpc", "main", #{
    "cidr_block": "10.0.0.0/16",
    "tags": #{"Name": "main-vpc", "Env": "prod"}
})
print(vpc)

Generate a variable block

Generates a variable block with an optional default value and description.

use plugin terraform::{terraform}

let v = terraform.build_variable("region", "string", r#""us-east-1""#, "AWS region to deploy into")
print(v)

Generate an output block

Generates an output block. value_expr is the HCL expression string assigned to value.

use plugin terraform::{terraform}

let out = terraform.build_output("bucket_arn", "aws_s3_bucket.my_bucket.arn")
print(out)

Generate a provider block

Generates a provider block with the given attributes table.

use plugin terraform::{terraform}

let p = terraform.build_provider("aws", #{"region": "us-east-1", "profile": "default"})
print(p)

Generate a data source block

Generates a data source block, which reads existing infrastructure without managing it.

use plugin terraform::{terraform}

let ami = terraform.build_data("aws_ami", "ubuntu", #{
    "most_recent": true,
    "owners": r#"["099720109477"]"#
})
print(ami)

Generate a locals block

Generates a locals block from a table of name-to-expression pairs.

use plugin terraform::{terraform}

let locals = terraform.build_locals(#{"env": r#""production""#, "prefix": r#""myapp""#})
print(locals)

Generate a module block

Generates a module block referencing the given source path or registry address.

use plugin terraform::{terraform}

let mod = terraform.build_module("terraform-aws-modules/vpc/aws", "vpc", #{
    "version": r#""3.0.0""#,
    "cidr": r#""10.0.0.0/16""#
})
print(mod)

Generate a terraform required_providers block

Generates a terraform { required_providers { ... } } block. Each key maps to a table with source and version.

use plugin terraform::{terraform}

let tf = terraform.build_terraform(#{
    "aws": #{"source": "hashicorp/aws", "version": "~> 5.0"}
})
print(tf)

Generate a terraform backend block

Generates a terraform { backend "type" { ... } } block for remote state configuration.

use plugin terraform::{terraform}

let backend = terraform.build_backend("s3", #{
    "bucket": "my-tfstate",
    "key": "prod/terraform.tfstate",
    "region": "us-east-1"
})
print(backend)

Generate a provisioner block

Generates a standalone provisioner block. Embed it inside a resource string using concat_blocks.

use plugin terraform::{terraform}

let prov = terraform.build_provisioner("local-exec", #{"command": "echo done"})
print(prov)

Join multiple HCL blocks into one string

Joins a table of HCL block strings together with newlines between them, producing a single file-ready string.

use plugin terraform::{terraform}

let provider = terraform.build_provider("aws", #{"region": "us-east-1"})
let bucket = terraform.build_resource("aws_s3_bucket", "assets", #{"bucket": "my-assets"})
let output = terraform.build_output("bucket_name", "aws_s3_bucket.assets.bucket")

let file = terraform.concat_blocks([provider, bucket, output])
print(file)

Wrap a value as a quoted HCL string

Wraps val in escaped HCL double quotes. Useful when building expressions to pass to build_variable or build_locals.

use plugin terraform::{terraform}

print(terraform.hcl_string("us-east-1"))

Render a table as an HCL list literal

Renders a table of values as an HCL list literal, e.g. ["a", "b"].

use plugin terraform::{terraform}

let zones = terraform.hcl_list(["us-east-1a", "us-east-1b", "us-east-1c"])
print(zones)

Render a table as an HCL map literal

Renders a table as an HCL map literal { key = value ... }. Useful for inline map attributes.

use plugin terraform::{terraform}

let tags = terraform.hcl_map(#{"Env": r#""prod""#, "Team": r#""platform""#})
print(tags)

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en