Description
With Terraform AWS provider v6.14.0, enabling encrypt_at_rest without a kms_key_id uses the default aws/es KMS key. Choose a customer managed key if you need to control the key policy and lifecycle.
Potential impact
The default key may not meet your separation-of-duties requirements. Disabling or deleting a customer managed key in use can interrupt data access.
Remediation
Check the deployed encryption state and key. For a new domain that needs a customer managed key, set kms_key_id to the approved symmetric key ARN and give the service access. Changing an encrypted domain’s key makes Terraform replace the domain. Keep the source and recovery options available, migrate to a separately named domain and test access and recovery before switching. Limit who can disable or delete the customer managed key.
Examples
Both excerpts enable encryption. The second chooses a key through var.encryption_key_arn. For a new domain, use Elasticsearch 5.1 or later with a supported instance type, and configure storage, access policies and networking.
Use the default service key
resource "aws_elasticsearch_domain" "search_domain" {
domain_name = "example"
elasticsearch_version = var.elasticsearch_version
encrypt_at_rest {
enabled = true
}
}
Specify a customer managed key
resource "aws_elasticsearch_domain" "search_domain" {
domain_name = "example"
elasticsearch_version = var.elasticsearch_version
encrypt_at_rest {
enabled = true
kms_key_id = var.encryption_key_arn
}
}