Skip to content

Commit 5849958

Browse files
author
Sohan Yadav
authored
Merge pull request #18 from clouddrove/bridgecrew
security fixes added
2 parents 6e8232d + 9e3a34a commit 5849958

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

_example/basic_example/example.tf

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,36 @@ module "iam-role" {
7171
policy = data.aws_iam_policy_document.iam-policy.json
7272
}
7373

74+
module "kms_key" {
75+
source = "clouddrove/kms/aws"
76+
version = "0.14.0"
77+
name = "kms"
78+
environment = "test"
79+
label_order = ["environment", "name"]
80+
enabled = true
81+
description = "KMS key for ec2"
82+
deletion_window_in_days = 7
83+
enable_key_rotation = true
84+
alias = "alias/ec2"
85+
policy = data.aws_iam_policy_document.kms.json
86+
}
87+
88+
89+
data "aws_iam_policy_document" "kms" {
90+
version = "2012-10-17"
91+
statement {
92+
sid = "Enable IAM User Permissions"
93+
effect = "Allow"
94+
principals {
95+
type = "AWS"
96+
identifiers = ["*"]
97+
}
98+
actions = ["kms:*"]
99+
resources = ["*"]
100+
}
101+
102+
}
103+
74104
data "aws_iam_policy_document" "default" {
75105
statement {
76106
effect = "Allow"
@@ -108,7 +138,6 @@ module "ec2" {
108138
ami = "ami-08d658f84a6d84a80"
109139
instance_type = "t2.nano"
110140
monitoring = false
111-
encrypted = false
112141
tenancy = "default"
113142
vpc_security_group_ids_list = [module.ssh.security_group_ids, module.http-https.security_group_ids]
114143
subnet_ids = tolist(module.public_subnets.public_subnet_id)
@@ -128,4 +157,5 @@ module "ec2" {
128157
instance_tags = { "snapshot" = true }
129158
dns_zone_id = "Z1XJD7SSBKXLC1"
130159
hostname = "ec2"
160+
kms_key_id = module.kms_key.key_arn
131161
}

_example/secure_example/.terraform.lock.hcl

Lines changed: 0 additions & 21 deletions
This file was deleted.

_example/secure_example/example.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ module "ec2" {
160160
ebs_volume_enabled = true
161161
ebs_volume_type = "gp2"
162162
ebs_volume_size = 30
163-
encrypted = true
164163
kms_key_id = module.kms_key.key_arn
165164
instance_tags = { "snapshot" = true }
166165
dns_zone_id = "Z1XJD7SSBKXLC1"

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ resource "aws_instance" "default" {
5050
root_block_device {
5151
volume_size = var.disk_size
5252
delete_on_termination = true
53-
encrypted = var.encrypted
53+
encrypted = true
5454
kms_key_id = var.kms_key_id
5555
}
5656

@@ -111,7 +111,7 @@ resource "aws_ebs_volume" "default" {
111111
size = var.ebs_volume_size
112112
iops = local.ebs_iops
113113
type = var.ebs_volume_type
114-
encrypted = var.encrypted
114+
encrypted = true
115115
kms_key_id = var.kms_key_id
116116
tags = merge(
117117
module.labels.tags,

variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,3 @@ variable "kms_key_id" {
323323
description = "The ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true."
324324
sensitive = true
325325
}
326-
327-
variable "encrypted" {
328-
type = bool
329-
default = true
330-
description = "If true, the disk will be encrypted."
331-
}

0 commit comments

Comments
 (0)