Flashcards
4 Terraform basics
Cards in this deck (34)
- 1URL of providersregistry.terraform.io
- 2What kind of providers are available?Official
Verified
Community - 3In which hidden folder are plugins downloaded?.terraform/plugins in the working directory
- 4What does hashicorp represent in the following: hashicorp/local: version =Organisational namespace
- 5What does local represent in the following: hashicorp/local: version =type (name of provider)
- 6Create variable content in variable.tf (default = "This is test") in variables.tf filevariable "content" {
default = "This is test"
} - 7Replace content in the following block with variable content from variables.tf resource "local_file" "pet" { filename = "/root/pets.txt" content = "This is test"}resource "local_file" "pet" {
filename = "/root/pets.txt"
content = var.content} - 8What are optional parameters in variable block in addition to default?type
description - 9What are basic possible values in type parameter?string, number and boolean
- 10What can string type show?alphabet and number
- 11What can number type show?Positive or negative number
- 12What are remaining types?list, map, set, object, tuple
- 13What is default value of type if not specified?any
- 14The following variable is given: variable "prefix" { default = ["Mr", "Mrs", "Sir" ] type = list } How can you access Mrs in main.tf config fileresource "random_pet" "my-pet" {
prefix = var.prefix[1]"
} - 15The following variable is given: variable file-content { type = map default = { "statement1" = "I feel good" "statement2" = "I feel OK" } } How can you access statement 1 in main.tf config file How can you access Mrs in main.tf config gileresource "local_file" "my-feeling" {
filename = "/root/feeling.txt"
content = var.file-content [statement1]
} - 16Indicate variable reqem_list which has to be list of numbersvariable "reqem_list" {
default = [ 1, 2, 3 ]
type = list(number)
} - 17Indicate variable reqem_map which has to be map of numbers (bir:1, iki:2)variable "reqem_map" {
default = {
"bir" = 1
"iki" = 2
}
type = map(number)
} - 18Indicate variable meyve_set which has to be set of strings ("alma", "armud")variable "meyve_set" {
default = ["alma", "armud"]
type = set(string)
} - 19Indicate variable reqem_set which has to be set of numbers (5, 10)variable "reqem_set" {
default = [ 5, 10 ]
type = set(number)
} - 20Declare variable future_car which has to be object type with following (make: string, year:number, country: list of string, euro4: boolean) and assign some valuesvariable "future_car" {
type = object ({
make = string
year = number
country = list(string)
euro4 = bool
})
default = {
make = "Toyota"
year = 2015
country = ["Germany", "Japan"]
euro4 = true
}
} - 21Declare variable future_car which has to be tuple type with following string, number, bool) and assign some valuesvariable future_car {
type = tuple([string, number, bool])
default = ["Mercedes", 2018, true]
} - 22What would happen if we have variables like this: vaiable "filename" { } variable "content" { }When we run terraform apply we would be prompted to enter each value
- 23How can we pass values to the following variables in terminal directly variable "filename" { default = "/root/pets.txt" } variable "content" { default = "We love pets" }terraform apply -var "filename=/root/pets.txt" -var "content=We love pets"
- 24How can we pass in the following variables using export command: variable "filename" { default = "/root/pets.txt" } variable "content" { default = "We love pets" }export TF_VAR_filename = "/root/pets.txt"
export_TF_VAR_content = "We love pets" - 25What should be name or ending of the variable definiion files?terraform.tfvars
terraform.tfvars.json
.auto.tfvars
.autotfvars.json - 26How can we pass in the following variables using terraform.tfvars file: variable "filename" { default = "/root/pets.txt" } variable "content" { default = "We love pets" }filename = "/root/pets.txt"
content = "We love pets" - 27What should we do if we use variable definition file variable.tfvarsterraform apply -var-file variables.tfvars
- 28Variable filename was defined in the following ways: filename = "/root/pets.txt" (terraform.tfvars) export TF_VAR_filename = "/root/cats.txt" terraform apply -var "filename=/root/best-pet.txt" filename = "/root/mypet.txt" What will the final result?/root/best-pet.txt
- 29Explain order of variable definition.Env variables (export)
terraform.tfvars
*.auto.tfvars
-var or -var-file after apply - 30resource "local_file" "pet" { filename = var.filename content = "My favorite pet is ...." } resource "random_pet" "my-pet" { prefix = var.prefix separator = var.separator length = var.length } Fill in the blank with id of my-petresource "local_file" "pet" {
filename = var.filename
content = "My favorite pet is ${random_pet.my-pet.id}"
} - 31resource "local_file" "pet" { filename = var.filename content = "My favorite pet is Mr.Cat" } resource "random_pet" "my-pet" { prefix = var.prefix separator = var.separator length = var.length } Make sure that local_file is created after random_petresource "local_file" "pet" {
filename = var.filename
content = "My favorite pet is Mr.Cat"
depends_on = [
random_pet.my-pet
]
} - 32Add output variable pet-name with value which display id of my-pet and add some descriptionoutput pet-name {
value = random_pet.my-pet.id
description = "some text"
} - 33How can you display output besides terraform applyterraform output
- 34Using terraform output print out value of pet-nameterraform output pet-name
Information
- Description
- Easy Kodekloud Terraform basics Flashcards on 4 Terraform basics, created by Archimed Nemes on 15/12/2022.
- Created by
- Archimed Nemes
- Views
- 0
- Rating