Terraform Core Commands

Looking to take your Terraform workflow to the next level? Check out our comprehensive guide to Terraform Core Commands!

In this post, we’ll highlight some of the most commonly used Terraform Core Commands. So whether you’re just getting started with Terraform or you’re looking to up your game, be sure to check out this guide!

Terraform commands

–help is help

Tab completion enabled by terraform -install-autocomplete

[table id=2 /]

Subcommands

[table id=3 /]

Terraform Syntax

The syntax of Terraform configurations is called HashiCorp Configuration Language (HCL). It is meant to strike a balance between human readable and editable as well as being machine-friendly. For machine-friendliness, Terraform can also read JSON configurations

HCL Syntax (HashiCorp Configuration Language)

Here is an example of HashiCorp Configuration Language (HCL)

# An AMI
variable "ami" {
description = "the AMI to use"
}
/* A multi
line comment. */
resource "aws_instance" "web" {
ami = "${var.ami}"
count = 2
source_dest_check = false
connection {
user = "root"
}
} 

Source: https://www.terraform.io/docs/configuration/syntax.html

JSON Syntax

Terraform also supports JSON which is a machine friendly language

{
"variable": {
"ami": {
"description": "the AMI to use"
}
},
"resource": {
"aws_instance": {
"web": {
"ami": "${var.ami}",
"count": 2,
"source_dest_check": false,
"connection": {
"user": "root"
}
}
}
}
} 

Source: https://www.terraform.io/docs/configuration/syntax.html

Variables

[table id=4 /]

Elsewhere On TurboGeek:  Grep and RegEx One-Liners

You may also like...

3 Responses

  1. 19/10/2022

    […] is a tool that automates the configuration of infrastructure. It can help you manage your servers, databases, and applications more effectively. It can also […]

  2. 22/10/2022

    […] Terraform Core Commands […]

  3. 19/01/2023

    […] Terraform Core Commands […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »