Secrets Manager secret encrypted with an AWS managed key

Check whether the AWS managed Secrets Manager key meets your key-management requirements.

Description

Secrets Manager encrypts secret values with aws/secretsmanager by default. Choose a customer-managed KMS key if you need to set the key policy or manage the key's lifecycle.

Potential impact

Read access depends on the secret policy, IAM permissions and key policy. Incorrect permissions can block applications from reading a secret.

Remediation

Set kms_key_id to the ARN or alias of a symmetric customer-managed KMS key in the same Region. Grant only the required secret-read and key-use permissions. Test that applications can read the versions they need before removing access to a previous key.

Examples

The examples select the key for the same secret. The secret value is managed separately.

AWS managed key

hcl
resource "aws_secretsmanager_secret" "example" {
  name       = "test-cloudrail-1"
  kms_key_id = "alias/aws/secretsmanager"
}

alias/aws/secretsmanager selects the AWS managed key.

Customer-managed key

hcl
resource "aws_secretsmanager_secret" "example" {
  name       = "test-cloudrail-1"
  kms_key_id = "alias/MyAlias"
}

Replace alias/MyAlias with the alias of your customer-managed key.

References