1. Declarative Language
The Terraform language is declarative, describing an intended goal rather than the steps to reach that goal. The ordering of blocks and the files they are organized into are generally not significant; Terraform only considers implicit and explicit relationships between resources when determining an order of operations.
Example
Imagine you are making a sandwich with both a regular programming language (imperative) and Terraform (declarative). Your imperative code might look like this.
def make_sandwich(ingredients):
slices = get_bread(slices = 2)
butter_bread(bread = slices)
for ingredient in ingredients:
add_ingredient(bread = slices, ingredient = ingredient)
combine_slices(slices)
return slices
my_sandwich = make_sandwich(["ham", "cheese"])
In this context you need to walk through the making of your sandwich step by step, as the language itself has no concept of how to do it. In a declarative language, on the other hand, a provider tells the language how to do the making of your sandwich, and all you need to do is provide the options. Like this:
resource "sandwich" "my_sandwich" {
ingredients = [
"ham",
"cheese"
]
}
Here, Terraform uses its "sandwich" resource to do all the hard work behind the scenes, and all you need to provide is the options. Some of these are required, others might be optional, such as the type of bread, or whatever.