What is the main purpose of the import block introduced in Terraform 1.5+?
Think about how Terraform manages existing resources that were created outside Terraform.
The import block allows Terraform to bring existing infrastructure into its state automatically during terraform apply, avoiding manual import commands.
Which of the following Terraform snippets correctly uses the import block syntax introduced in Terraform 1.5+ to import an AWS S3 bucket with ID my-bucket?
The import block requires id and to attributes. The order matters for clarity.
The correct syntax uses id to specify the resource ID and to to specify the resource address. Option D follows this correctly.
What happens when Terraform runs terraform apply with a configuration that includes an import block for a resource that already exists in the cloud provider but is not yet in the Terraform state?
Consider how Terraform handles existing resources declared in the import block during apply.
Terraform automatically imports the existing resource into its state during apply, so it can manage it going forward without manual import commands.
Which security risk is most relevant when using Terraform's import block to bring existing cloud resources into state?
Think about what information is stored in Terraform state files after import.
Imported resources' details, including sensitive data, are stored in the Terraform state file. If this file is not secured, it can expose sensitive information.
Given a Terraform configuration with two import blocks referencing the same resource address but different IDs, what will happen during terraform apply?
Consider how Terraform handles conflicting state imports for the same resource address.
Terraform does not allow multiple import blocks for the same resource address with different IDs. It raises an error to prevent state conflicts.