Skip to content

Commit

Permalink
feat: changes module description
Browse files Browse the repository at this point in the history
  • Loading branch information
theprashantyadav committed Jun 14, 2023
1 parent 946056c commit c651142
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 56 deletions.
18 changes: 8 additions & 10 deletions _example/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ module "kms_key" {
environment = "test"
label_order = ["name", "environment"]

deletion_window_in_days = 7
alias = "alias/cloudtrail_Name"
enabled = true
kms_key_enabled = true
multi_region = true
create_replica_external_enabled = false
create_replica_enabled = false
create_external_enabled = true
valid_to = "2023-11-21T23:20:50Z"
key_material_base64 = "Wblj06fduthWggmsT0cLVoIMOkeLbc2kVfMud77i/JY="
deletion_window_in_days = 7
alias = "alias/cloudtrail_Name"
enabled = true
kms_key_enabled = true
multi_region = true
create_external_enabled = true
valid_to = "2023-11-21T23:20:50Z"
key_material_base64 = "Wblj06fduthWggmsT0cLVoIMOkeLbc2kVfMud77i/JY="
}
37 changes: 3 additions & 34 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,9 @@ resource "aws_kms_external_key" "external" {
tags = module.labels.tags
}

resource "aws_kms_replica_key" "replica-key" {
count = var.enabled && var.create_replica_enabled ? 1 : 0

bypass_policy_lockout_safety_check = var.bypass_policy_lockout_safety_check
deletion_window_in_days = var.deletion_window_in_days
description = var.description
primary_key_arn = var.primary_key_arn == "" ? join("", aws_kms_key.default.*.arn) : var.primary_key_arn
enabled = var.is_enabled
policy = data.aws_iam_policy_document.default.json

tags = module.labels.tags
}

####----------------------------------------------------------------------------------
## Replica External Key.
####----------------------------------------------------------------------------------
resource "aws_kms_replica_external_key" "replica-external-key" {
count = var.enabled && var.create_replica_external_enabled ? 1 : 0

bypass_policy_lockout_safety_check = var.bypass_policy_lockout_safety_check
deletion_window_in_days = var.deletion_window_in_days
description = var.description
enabled = var.is_enabled
key_material_base64 = var.key_material_base64
policy = data.aws_iam_policy_document.default.json
primary_key_arn = join("", aws_kms_key.default.*.arn)
valid_to = var.valid_to

tags = module.labels.tags
}


# Module : KMS ALIAS
# Description : Provides an alias for a KMS customer master key..
##----------------------------------------------------------------------------------
## Provides an alias for a KMS customer master key.
##----------------------------------------------------------------------------------
resource "aws_kms_alias" "default" {
count = var.enabled ? 1 : 0

Expand Down
12 changes: 0 additions & 12 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,6 @@ variable "key_material_base64" {
description = "Base64 encoded 256-bit symmetric encryption key material to import. The CMK is permanently associated with this key material. External key only"
}

variable "create_replica_external_enabled" {
type = bool
default = false
description = "Determines whether a replica external CMK will be created (externally provided material)"
}

variable "create_replica_enabled" {
type = bool
default = false
description = "Determines whether a replica standard CMK will be created (AWS provided material)"
}

variable "create_external_enabled" {
type = bool
default = false
Expand Down

0 comments on commit c651142

Please sign in to comment.