Syntax - Configuration Language | Terraform | HashiCorp Developer - 0 views
-
the native syntax of the Terraform language, which is a rich language designed to be relatively easy for humans to read and write.
-
Terraform's configuration language is based on a more general language called HCL, and HCL's documentation usually uses the word "attribute" instead of "argument."
- ...34 more annotations...
-
Identifiers can contain letters, digits, underscores (_), and hyphens (-). The first character of an identifier must not be a digit, to avoid ambiguity with literal numbers.
-
Avoid separating multiple blocks of the same type with other blocks of a different type, unless the block types are defined by semantics to form a family.
-
Resource names must start with a letter or underscore, and may contain only letters, digits, underscores, and dashes.
-
Each resource is associated with a single resource type, which determines the kind of infrastructure object it manages and what arguments and other attributes the resource supports.
-
Each resource type is implemented by a provider, which is a plugin for Terraform that offers a collection of resource types.
-
Most publicly available providers are distributed on the Terraform Registry, which also hosts their documentation.
-
The Terraform language defines several meta-arguments, which can be used with any resource type to change the behavior of resources.
-
use precondition and postcondition blocks to specify assumptions and guarantees about how the resource operates.
-
Some resource types provide a special timeouts nested block argument that allows you to customize how long certain operations are allowed to take before being considered to have failed.
-
A resource block declares that you want a particular infrastructure object to exist with the given settings.
-
Destroy and re-create resources whose arguments have changed but which cannot be updated in-place due to remote API limitations.
-
Expressions within a Terraform module can access information about resources in the same module, and you can use that information to help configure other resources. Use the <RESOURCE TYPE>.<NAME>.<ATTRIBUTE> syntax to reference a resource attribute in an expression.
-
resources often provide read-only attributes with information obtained from the remote API; this often includes things that can't be known until the resource is created, like the resource's unique random ID.
-
local-only resource types exist for generating private keys, issuing self-signed TLS certificates, and even generating random ids.
-
The behavior of local-only resources is the same as all other resources, but their result data exists only within the Terraform state.
-
The count meta-argument accepts a whole number, and creates that many instances of the resource or module.
-
the count value must be known before Terraform performs any remote resource actions. This means count can't refer to any resource attributes that aren't known until after a configuration is applied
-
Within nested provisioner or connection blocks, the special self object refers to the current resource instance, not the resource block as a whole.
-
This was fragile, because the resource instances were still identified by their index instead of the string values in the list.