terraform init with a configured backend, what is the main action Terraform performs?terraform init does before any changes happen.Running terraform init downloads necessary provider plugins and sets up the backend, which is where Terraform stores its state file remotely. It does not apply or destroy resources at this stage.
terraform init -migrate-state. What is the expected result?-migrate-state flag is designed to do.The -migrate-state flag tells Terraform to move the existing state from the current backend (local) to the new backend (remote) during initialization. This preserves the state and avoids resource duplication.
terraform {
backend "local" {
path = "terraform.tfstate"
}
}
You want to migrate to an S3 backend. Which backend configuration block correctly sets up the S3 backend for migration?The S3 backend requires bucket, key, and region attributes. The key is the path inside the bucket. The region must be correct. Option B uses correct attribute names and region.
Encrypting the state file on the server side and restricting access with IAM policies ensures that sensitive information in the state is protected from unauthorized access.
State locking prevents multiple users from making changes to the state at the same time, avoiding conflicts and corruption. This means only one user can apply changes at once.