-
Notifications
You must be signed in to change notification settings - Fork 3
/
kms.tf
28 lines (24 loc) · 971 Bytes
/
kms.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* --------------------------------------------------------
FILE: kms.tf
This file is used to declare a KMS key with a custom policy
to be used in the Glue job security configuration
-------------------------------------------------------- */
# Creating a KMS key
resource "aws_kms_key" "glue_cmk" {
count = var.mode == "learning" || var.flag_create_kms_key ? 1 : 0
description = "KMS Key for encrypting S3 data and CloudWatch logs"
key_usage = "ENCRYPT_DECRYPT"
customer_master_key_spec = "SYMMETRIC_DEFAULT"
is_enabled = true
enable_key_rotation = false
policy = local.kms_policy_prep
}
# Defining a key alias
resource "aws_kms_alias" "glue_cmk" {
count = var.mode == "learning" || var.flag_create_kms_key ? 1 : 0
name = var.kms_key_alias
target_key_id = aws_kms_key.glue_cmk[count.index].key_id
depends_on = [
aws_kms_key.glue_cmk
]
}