You can migrate the Terraform backend but only if there are no resources currently being managed.
Correct Answer: A
If you need to migrate to another backend, such as Terraform Cloud, so you can continue managing it. By migrating your Terraform state, you can hand off infrastructure without de-provisioning anything. https://www.terraform.io/docs/cloud/migrate/index.html
Question 152
Where does the Terraform local backend store its state?
Correct Answer: C
The local backend stores state on the local filesystem, locks that state using system APIs, and performs operations locally. Reference: https://www.terraform.io/docs/language/settings/backends/local.html
Question 153
What is the default backend for Terraform?
Correct Answer: C
Explanation By default, Terraform uses the "local" backend, which is the normal behavior of Terraform you're used to. https://www.terraform.io/docs/backends/index.html
Question 154
Anyone can publish and share modules on the Terraform Public Module Registry, and meeting the requirements for publishing a module is extremely easy. Select from the following list all valid requirements. (select three)
You have declared a variable name my_var in terraform configuration without a value associated with it. variable my_var {} After running terraform plan it will show an error as variable is not defined.
Correct Answer: B
Explanation Input variables are usually defined by stating a name, type and a default value. However, the type and default values are not strictly necessary. Terraform can deduct the type of the variable from the default or input value. Variables can be predetermined in a file or included in the command-line options. As such, the simplest variable is just a name while the type and value are selected based on the input. variable "variable_name" {} terraform apply -var variable_name="value" The input variables, like the one above, use a couple of different types: strings, lists, maps, and boolean. Here are some examples of how each type are defined and used. String Strings mark a single value per structure and are commonly used to simplify and make complicated values more user-friendly. Below is an example of a string variable definition. variable "template" { type = string default = "01000000-0000-4000-8000-000030080200" } A string variable can then be used in resource plans. Surrounded by double quotes, string variables are a simple substitution such as the example underneath. storage = var.template List Another type of Terraform variables lists. They work much like a numbered catalogue of values. Each value can be called by their corresponding index in the list. Here is an example of a list variable definition. variable "users" { type = list default = ["root", "user1", "user2"] } Lists can be used in the resource plans similarly to strings, but you'll also need to denote the index of the value you are looking for. username = var.users[0] Map Maps are a collection of string keys and string values. These can be useful for selecting values based on predefined parameters such as the server configuration by the monthly price. variable "plans" { type = map default = { "5USD" = "1xCPU-1GB" "10USD" = "1xCPU-2GB" "20USD" = "2xCPU-4GB" } } You can access the right value by using the matching key. For example, the variable below would set the plan to "1xCPU-1GB". plan = var.plans["5USD"] The values matching to their keys can also be used to look up information in other maps. For example, underneath is a shortlist of plans and their corresponding storage sizes. variable "storage_sizes" { type = map default = { "1xCPU-1GB" = "25" "1xCPU-2GB" = "50" "2xCPU-4GB" = "80" } } These can then be used to find the right storage size based on the monthly price as defined in the previous example. size = lookup(var.storage_sizes, var.plans["5USD"]) Boolean The last of the available variable type is boolean. They give the option to employ simple true or false values. For example, you might wish to have a variable that decides when to generate the root user password on a new deployment. variable "set_password" { default = false } The above example boolean can be used similarly to a string variable by simply marking down the correct variable. create_password = var.set_password By default, the value is set to false in this example. However, you can overwrite the variable at deployment by assigning a different value in a command-line variable. terraform apply -var set_password="true"