0
0
Terraformcloud~20 mins

JSON configuration alternative in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform JSON Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Configuration
intermediate
2:00remaining
Identify the correct JSON equivalent of a Terraform resource block
Given the following Terraform HCL resource block, which JSON configuration correctly represents it?
resource "aws_s3_bucket" "example" {
  bucket = "my-bucket"
  acl    = "private"
}
A
{
  "resource": {
    "aws_s3_bucket": {
      "example": {
        "bucket": "my-bucket",
        "acl": "private"
      }
    }
  }
}
B
{
  "aws_s3_bucket": {
    "example": {
      "bucket": "my-bucket",
      "acl": "private"
    }
  }
}
C
{
  "resource": {
    "aws_s3_bucket": {
      "example": [
        {
          "bucket": "my-bucket",
          "acl": "private"
        }
      ]
    }
  }
}
D
{
  "resource": {
    "aws_s3_bucket": {
      "example": {
        "name": "my-bucket",
        "access_control": "private"
      }
    }
  }
}
Attempts:
2 left
💡 Hint
Remember that Terraform JSON uses nested objects under "resource" with resource type and name keys.
service_behavior
intermediate
1:30remaining
What happens if a required attribute is missing in Terraform JSON config?
If you omit a required attribute like "bucket" in the JSON configuration for an aws_s3_bucket resource, what will Terraform do when you run apply?
ATerraform will create the resource but with empty or null values for missing attributes.
BTerraform will throw a validation error and refuse to apply the configuration.
CTerraform will apply the configuration successfully with default values for missing attributes.
DTerraform will ignore the resource block entirely and continue with other resources.
Attempts:
2 left
💡 Hint
Think about how Terraform validates required fields before creating resources.
Architecture
advanced
2:30remaining
How to represent multiple resources in Terraform JSON configuration?
You want to define two aws_s3_bucket resources named "bucket1" and "bucket2" in Terraform JSON. Which JSON snippet correctly represents this?
A
{
  "resource": {
    "aws_s3_bucket": {
      "bucket1": {"bucket": "bucket-one", "acl": "private"},
      "bucket2": {"bucket": "bucket-two", "acl": "public-read"}
    }
  }
}
B
{
  "resource": [
    {"aws_s3_bucket": {"bucket1": {"bucket": "bucket-one", "acl": "private"}}},
    {"aws_s3_bucket": {"bucket2": {"bucket": "bucket-two", "acl": "public-read"}}}
  ]
}
C
{
  "resource": {
    "aws_s3_bucket": [
      {"bucket1": {"bucket": "bucket-one", "acl": "private"}},
      {"bucket2": {"bucket": "bucket-two", "acl": "public-read"}}
    ]
  }
}
D
{
  "resource": {
    "aws_s3_bucket": {
      "bucket1": {"bucket": "bucket-one", "acl": "private"}
    },
    "aws_s3_bucket": {
      "bucket2": {"bucket": "bucket-two", "acl": "public-read"}
    }
  }
}
Attempts:
2 left
💡 Hint
Remember JSON keys must be unique; multiple resources of the same type are nested under the same resource type key.
security
advanced
2:00remaining
How to securely manage sensitive variables in Terraform JSON configuration?
You have a sensitive variable like a database password. Which approach is best to avoid exposing it directly in Terraform JSON configuration files?
AEncrypt the password manually and store the encrypted string in the JSON configuration.
BStore the password in a separate JSON file in the same directory and import it.
CUse environment variables or Terraform Cloud workspace variables and reference them in JSON without hardcoding.
DHardcode the password directly in the JSON configuration under a variable block.
Attempts:
2 left
💡 Hint
Think about how Terraform handles sensitive data securely without exposing it in config files.
🧠 Conceptual
expert
1:30remaining
What is the main difference between Terraform HCL and JSON configuration formats?
Which statement best describes the key difference between Terraform's HCL and JSON configuration formats?
AJSON supports dynamic expressions and functions, while HCL does not.
BJSON configuration files are only used for Terraform Cloud and not for local Terraform runs.
CHCL configurations cannot be converted to JSON format.
DHCL supports comments and more readable syntax, while JSON does not support comments and is more verbose.
Attempts:
2 left
💡 Hint
Consider readability and syntax features of both formats.