0
0
GCPcloud~10 mins

Variables and outputs in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable in a Terraform configuration.

GCP
variable "project_id" {
  type = [1]
}
Drag options to blanks, or click blank then click option'
Ainteger
Bstring
Cbool
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using integer or bool types for text values.
Leaving the type undefined.
2fill in blank
medium

Complete the code to output the project ID variable value.

GCP
output "project_id_output" {
  value = [1]
}
Drag options to blanks, or click blank then click option'
Aproject_id
Bvar.project_name
Coutput.project_id
Dvar.project_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using the output name instead of the variable name.
Omitting the var. prefix.
3fill in blank
hard

Fix the error in the output block to correctly reference the variable.

GCP
output "region_output" {
  value = [1]
}
Drag options to blanks, or click blank then click option'
Avar.region
Bvar.region_name
Coutput.region
Dregion
Attempts:
3 left
💡 Hint
Common Mistakes
Referencing variables without the var. prefix.
Using incorrect variable names.
4fill in blank
hard

Fill both blanks to declare a variable with a default value and output it.

GCP
variable "region" {
  type    = [1]
  default = [2]
}

output "region_output" {
  value = var.region
}
Drag options to blanks, or click blank then click option'
Astring
B"us-central1"
Cus-central1
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the default string value.
Using wrong type for the variable.
5fill in blank
hard

Fill all three blanks to declare a variable, assign a default, and output its uppercase value.

GCP
variable "env" {
  type    = [1]
  default = [2]
}

output "env_upper" {
  value = upper([3])
}
Drag options to blanks, or click blank then click option'
Astring
B"prod"
Cvar.env
Dprod
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the default string.
Using the variable name without var. prefix.
Using unquoted strings in output.