0
0
Terraformcloud~10 mins

Import block syntax (Terraform 1.5+) - Interactive Code Practice

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

Complete the code to import an AWS S3 bucket resource using the new import block syntax.

Terraform
resource "aws_s3_bucket" "example" {
  bucket = "my-bucket"

  import {
    id = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"bucket-001"
B"my-bucket-123"
C"my-bucket"
D"example-bucket"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different bucket name than the resource's bucket attribute.
Omitting quotes around the bucket name.
2fill in blank
medium

Complete the import block to import an AWS EC2 instance with ID i-1234567890abcdef0.

Terraform
resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  import {
    id = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"instance-01"
B"web-instance"
C"ami-0c55b159cbfafe1f0"
D"i-1234567890abcdef0"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the AMI ID instead of the instance ID.
Using the resource name instead of the instance ID.
3fill in blank
hard

Fix the error in the import block by completing the id field correctly for a Google Cloud Storage bucket named 'my-gcs-bucket'.

Terraform
resource "google_storage_bucket" "bucket" {
  name = "my-gcs-bucket"

  import {
    id = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"projects/_/buckets/my-gcs-bucket"
B"my-gcs-bucket"
C"gcs-bucket-001"
D"bucket-my-gcs"
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the bucket name as the id.
Using an incorrect resource path format.
4fill in blank
hard

Complete the import block to import an Azure resource group named 'my-resource-group' with the correct id.

Terraform
resource "azurerm_resource_group" "rg" {
  name     = "my-resource-group"
  location = "East US"

  import {
    id   = [1]
  }
}
Drag options to blanks, or click blank then click option'
A"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group"
B"my-resource-group"
C"azurerm_resource_group"
D"resource_group"
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the resource group name as id.
5fill in blank
hard

Fill both blanks to import a Kubernetes namespace named 'dev-namespace' with the correct id and provider alias 'k8s'.

Terraform
provider "kubernetes" {
  alias = "k8s"
  config_path = "~/.kube/config"
}

resource "kubernetes_namespace" "dev" {
  metadata {
    name = "dev-namespace"
  }

  import {
    id       = [1]
    provider = [2]
  }
}
Drag options to blanks, or click blank then click option'
A"dev-namespace"
B"kubernetes_namespace"
Ckubernetes.k8s
D"namespace-dev"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect provider reference syntax.
Using wrong id strings.