What does the terraform import command do when executed?
Think about whether terraform import changes the actual cloud resource or just Terraform's knowledge of it.
The terraform import command links an existing resource in the cloud to Terraform's state file. It does not create, delete, or modify the resource itself, nor does it change configuration files.
Which of the following is the correct syntax to import an AWS S3 bucket named my-bucket into Terraform resource aws_s3_bucket.example?
Remember the format is terraform import <resource_type.resource_name> <resource_id>.
The correct syntax uses the resource address followed by the resource ID as recognized by the cloud provider. For S3 buckets, the bucket name alone is the ID.
After importing an existing cloud resource into Terraform state using terraform import, what must you do to ensure Terraform manages the resource correctly in future runs?
Think about how Terraform knows what to manage after importing.
Importing only updates the state file. You must manually add the resource block in your configuration files so Terraform knows how to manage the resource in future plans and applies.
Which security risk is most relevant when using terraform import to add existing cloud resources to Terraform state?
Consider what information Terraform state files contain and how they are stored.
Terraform state files can contain sensitive information about resources. Importing resources adds their data to the state file, so securing the state file is critical to prevent data leaks.
You import a resource that depends on another resource not yet managed by Terraform. What happens when you run terraform plan after the import?
Think about how Terraform handles resources defined in configuration but not in state.
Terraform only manages resources defined in configuration and tracked in state. If a dependency is missing, Terraform plans to create it to satisfy dependencies.