Description
Check the encryption state and key ID on the ECS data disk. An encrypted disk without an explicit kms_key_id can use a service key or the key selected by account defaults.
Potential impact
Disabling or deleting the key can make disk data inaccessible.
Remediation
If a customer key is required, set encrypted = true, specify the approved key ID and grant ECS permission to use it. If Terraform plans to replace an attached disk, add a separate destination and keep the source until you have migrated and verified the data and switched attachments.
Examples
Both excerpts enable encryption. Replace the masked key ID in the second. The example uses alicloud_disk, renamed alicloud_ecs_disk in provider 1.122.0.
Encrypted disk without an explicit key
resource "alicloud_disk" "ecs_disk" {
availability_zone = "cn-beijing-b"
name = "New-disk"
description = "Hello ecs disk."
category = "cloud_efficiency"
size = "30"
encrypted = true
tags = {
Name = "TerraformTest"
}
}
Encrypted disk with an explicit key
resource "alicloud_disk" "ecs_disk" {
availability_zone = "cn-beijing-b"
name = "New-disk"
description = "Hello ecs disk."
category = "cloud_efficiency"
size = "30"
encrypted = true
kms_key_id = "2a6767f0-a16c-4679-a60f-13bf*****"
tags = {
Name = "TerraformTest"
}
}