0
0
Terraformcloud~20 mins

Writing configuration for imported resources in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Import Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Configuration
intermediate
2:00remaining
Identify the correct Terraform resource configuration after import

You imported an existing AWS S3 bucket named my-bucket using Terraform import. Which configuration correctly represents the imported resource to avoid drift?

Terraform
terraform import aws_s3_bucket.my_bucket my-bucket
A
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket"
  acl    = "private"
}
B
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket"
  region = "us-east-1"
}
C
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket"
  acl  = "private"
}
D
resource "aws_s3_bucket" "my_bucket" {
  bucket = "my-bucket"
  versioning = {
    enabled = true
  }
}
Attempts:
2 left
💡 Hint

Check the correct attribute name for the bucket identifier and minimal required attributes.

Architecture
intermediate
1:30remaining
Determine the correct Terraform import command for an existing resource

You want to manage an existing AWS EC2 instance with Terraform. The instance ID is i-0abcd1234efgh5678. Which import command correctly imports this resource?

Aterraform import aws_instance.my_instance my_instance
Bterraform import aws_ec2_instance.my_instance i-0abcd1234efgh5678
Cterraform import aws_instance.my_instance i-0abcd1234efgh5678
Dterraform import aws_ec2.my_instance i-0abcd1234efgh5678
Attempts:
2 left
💡 Hint

Check the correct Terraform resource type name for EC2 instances.

service_behavior
advanced
1:30remaining
Predict the behavior of Terraform after importing a resource without configuration

You imported an existing AWS RDS instance using Terraform import but did not add any resource block in your configuration files. What will happen when you run terraform plan?

ATerraform will show the resource as to be destroyed because it is not in configuration.
BTerraform will show the resource as to be created because it is missing in configuration.
CTerraform will raise an error about missing resource configuration.
DTerraform will show no changes because the resource is imported.
Attempts:
2 left
💡 Hint

Think about how Terraform treats imported resources without configuration.

security
advanced
1:30remaining
Identify the security risk when importing resources without state locking

You imported several AWS IAM roles into Terraform but did not enable state locking on your backend. What is the main security risk of this setup?

AImported IAM roles will be publicly accessible by default.
BTerraform will automatically delete IAM roles without confirmation.
CTerraform will encrypt the state file causing access issues.
DMultiple users can overwrite the Terraform state causing inconsistent IAM role permissions.
Attempts:
2 left
💡 Hint

Consider what happens when multiple users modify state files simultaneously.

Best Practice
expert
2:30remaining
Choose the best practice for managing imported resources in Terraform

After importing a complex AWS VPC with many sub-resources, what is the best practice to ensure your Terraform configuration matches the actual infrastructure?

AOnly import the main VPC resource and ignore sub-resources to reduce configuration complexity.
BManually write the full Terraform configuration matching the imported resources and run <code>terraform plan</code> to detect drift.
CDelete the imported resources and recreate them with Terraform to ensure configuration accuracy.
DUse <code>terraform refresh</code> to update the state without adding configuration.
Attempts:
2 left
💡 Hint

Think about how Terraform tracks resources and detects changes.