# tflint-ignore: terraform_standard_module_structure variable "enable_kms_acm" { description = "Enable customer managed key that can be used to encrypt/decrypt AWS ACM" type = bool default = false } # tflint-ignore: terraform_standard_module_structure variable "enable_key_rotation_acm" { description = "Enable key rotation for AWS ACM CMK" type = bool default = true } # tflint-ignore: terraform_standard_module_structure variable "enable_multi_region_acm" { description = "Enable multi-region for AWS ACM CMK" type = bool default = false } # tflint-ignore: terraform_standard_module_structure variable "override_policy_acm" { description = "A valid KMS key policy JSON document. If not specified, a canonical key policy will be used." type = string default = null } data "aws_iam_policy_document" "acm" { # checkov:skip=CKV_AWS_109: Not applicable, using condition # checkov:skip=CKV_AWS_111: Not applicable, using condition source_policy_documents = [data.aws_iam_policy_document.admin_kms_policy.json] statement { sid = "Allow creation of decryption grants for ACM" principals { type = "AWS" identifiers = ["*"] } actions = [ "kms:CreateGrant" ] resources = ["*"] condition { test = "StringEquals" variable = "kms:ViaService" values = [ "acm.${var.region}.amazonaws.com" ] } condition { test = "StringEquals" variable = "kms:CallerAccount" values = local.allowed_accounts_via_service } condition { test = "ForAllValues:StringEquals" variable = "kms:GrantOperations" values = [ "Decrypt" ] } condition { test = "Bool" variable = "kms:GrantIsForAWSResource" values = [true] } } statement { sid = "Allow creation of encryption grant for ACM" principals { type = "AWS" identifiers = ["*"] } actions = [ "kms:CreateGrant" ] resources = ["*"] condition { test = "StringEquals" variable = "kms:ViaService" values = [ "acm.${var.region}.amazonaws.com" ] } condition { test = "StringEquals" variable = "kms:CallerAccount" values = local.allowed_accounts_via_service } condition { test = "ForAllValues:StringEquals" variable = "kms:GrantOperations" values = [ "Encrypt", "ReEncryptFrom", "ReEncryptTo" ] } condition { test = "Bool" variable = "kms:GrantIsForAWSResource" values = [true] } } statement { sid = "Allow decrypt for ACM" principals { type = "AWS" identifiers = ["*"] } actions = [ "kms:Decrypt" ] resources = ["*"] condition { test = "StringEquals" variable = "kms:ViaService" values = [ "acm.${var.region}.amazonaws.com" ] } condition { test = "StringEquals" variable = "kms:CallerAccount" values = local.allowed_accounts_via_service } } statement { sid = "Deny re-encryption to any other key for ACM" principals { type = "AWS" identifiers = ["*"] } effect = "Deny" actions = [ "kms:ReEncrypt*" ] resources = ["*"] condition { test = "Bool" variable = "kms:ReEncryptOnSameKey" values = [false] } } }