Complete the code to enable encryption for the Terraform state backend.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-west-2"
[1] = true
}
}The correct attribute to enable encryption at rest in the S3 backend is encrypt set to true.
Complete the code to specify the KMS key for encrypting the Terraform state.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-west-2"
encrypt = true
[1] = "arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678"
}
}The correct attribute to specify the KMS key ARN in the S3 backend is kms_key_id.
Fix the error in the backend configuration to properly enable encryption at rest.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-west-2"
encrypt = [1]
}
}The encrypt attribute expects a boolean value true without quotes.
Fill both blanks to configure the S3 backend with encryption and a KMS key.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-west-2"
[1] = true
[2] = "arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678"
}
}Use encrypt to enable encryption and kms_key_id to specify the KMS key ARN.
Fill all three blanks to configure the S3 backend with encryption, KMS key, and versioning enabled.
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "state.tfstate"
region = "us-west-2"
[1] = true
[2] = "arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678"
[3] = true
}
}Use encrypt to enable encryption, kms_key_id for the KMS key, and versioning to enable versioning of the state files.