Skip to content

Commit d447dd3

Browse files
feat: added kms module and update module
1 parent 58586c1 commit d447dd3

File tree

3 files changed

+123
-18
lines changed

3 files changed

+123
-18
lines changed

_example/memcached/example.tf

+46-12
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,59 @@ module "memcached-sg" {
4343
allowed_ports = [11211]
4444
}
4545

46+
module "kms_key" {
47+
source = "clouddrove/kms/aws"
48+
version = "1.3.0"
49+
50+
name = "kms"
51+
environment = "test"
52+
label_order = ["name", "environment"]
53+
54+
enabled = true
55+
description = "KMS key for aurora"
56+
alias = "alias/aurora"
57+
key_usage = "ENCRYPT_DECRYPT"
58+
customer_master_key_spec = "SYMMETRIC_DEFAULT"
59+
deletion_window_in_days = 7
60+
is_enabled = true
61+
policy = data.aws_iam_policy_document.default.json
62+
}
63+
64+
data "aws_iam_policy_document" "default" {
65+
version = "2012-10-17"
66+
67+
statement {
68+
sid = "Enable IAM User Permissions"
69+
effect = "Allow"
70+
principals {
71+
type = "AWS"
72+
identifiers = ["*"]
73+
}
74+
actions = ["kms:*"]
75+
resources = ["*"]
76+
}
77+
}
78+
4679
module "memcached" {
4780
source = "./../../"
4881

4982
name = "memcached"
5083
environment = "test"
5184
label_order = ["name", "environment"]
5285

53-
cluster_enabled = true
54-
engine = "memcached"
55-
engine_version = "1.5.10"
56-
family = "memcached1.5"
57-
parameter_group_name = ""
58-
az_mode = "cross-az"
59-
port = 11211
60-
node_type = "cache.t2.micro"
61-
num_cache_nodes = 2
62-
subnet_ids = module.subnets.public_subnet_id
63-
security_group_ids = [module.memcached-sg.security_group_ids]
64-
availability_zones = ["eu-west-1a", "eu-west-1b"]
86+
cluster_enabled = true
87+
engine = "memcached"
88+
engine_version = "1.5.10"
89+
family = "memcached1.5"
90+
parameter_group_name = ""
91+
az_mode = "cross-az"
92+
port = 11211
93+
node_type = "cache.t2.micro"
94+
num_cache_nodes = 2
95+
kms_key_id = module.kms_key.key_arn
96+
subnet_ids = module.subnets.public_subnet_id
97+
security_group_ids = [module.memcached-sg.security_group_ids]
98+
availability_zones = ["eu-west-1a", "eu-west-1b"]
6599
extra_tags = {
66100
Application = "CloudDrove"
67101
}

_example/redis-cluster/example.tf

+39-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "aws" {
2-
region = "eu-west-1"
2+
region = "us-east-1"
33
}
44

55
module "vpc" {
@@ -20,7 +20,7 @@ module "subnets" {
2020
name = "subnets"
2121
environment = "test"
2222
label_order = ["name", "environment"]
23-
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
23+
availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c"]
2424
vpc_id = module.vpc.vpc_id
2525
type = "public"
2626
igw_id = module.vpc.igw_id
@@ -41,6 +41,40 @@ module "redis-sg" {
4141
allowed_ports = [6379]
4242
}
4343

44+
module "kms_key" {
45+
source = "clouddrove/kms/aws"
46+
version = "1.3.0"
47+
48+
name = "kms"
49+
environment = "test"
50+
label_order = ["name", "environment"]
51+
52+
enabled = true
53+
54+
description = "KMS key for aurora"
55+
alias = "alias/redis-cluster"
56+
key_usage = "ENCRYPT_DECRYPT"
57+
customer_master_key_spec = "SYMMETRIC_DEFAULT"
58+
deletion_window_in_days = 7
59+
is_enabled = true
60+
policy = data.aws_iam_policy_document.default.json
61+
}
62+
63+
data "aws_iam_policy_document" "default" {
64+
version = "2012-10-17"
65+
66+
statement {
67+
sid = "Enable IAM User Permissions"
68+
effect = "Allow"
69+
principals {
70+
type = "AWS"
71+
identifiers = ["*"]
72+
}
73+
actions = ["kms:*"]
74+
resources = ["*"]
75+
}
76+
}
77+
4478
module "redis-cluster" {
4579
source = "./../../"
4680

@@ -54,13 +88,14 @@ module "redis-cluster" {
5488
parameter_group_name = "default.redis6.x.cluster.on"
5589
port = 6379
5690
node_type = "cache.t2.micro"
91+
kms_key_id = module.kms_key.key_arn
5792
subnet_ids = module.subnets.public_subnet_id
5893
security_group_ids = [module.redis-sg.security_group_ids]
59-
availability_zones = ["eu-west-1a", "eu-west-1b"]
94+
availability_zones = ["us-east-1a", "us-east-1b"]
6095
auto_minor_version_upgrade = true
6196
replicas_per_node_group = 2
6297
num_node_groups = 1
63-
snapshot_retention_limit = 7
98+
snapshot_retention_limit = 7
6499
automatic_failover_enabled = true
65100
extra_tags = {
66101
Application = "CloudDrove"

_example/redis/example.tf

+38-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,39 @@ module "redis-sg" {
4141
allowed_ports = [6379]
4242
}
4343

44+
module "kms_key" {
45+
source = "clouddrove/kms/aws"
46+
version = "1.3.0"
47+
48+
name = "kms"
49+
environment = "test"
50+
label_order = ["name", "environment"]
51+
52+
enabled = true
53+
description = "KMS key for aurora"
54+
alias = "alias/redis"
55+
key_usage = "ENCRYPT_DECRYPT"
56+
customer_master_key_spec = "SYMMETRIC_DEFAULT"
57+
deletion_window_in_days = 7
58+
is_enabled = true
59+
policy = data.aws_iam_policy_document.default.json
60+
}
61+
62+
data "aws_iam_policy_document" "default" {
63+
version = "2012-10-17"
64+
65+
statement {
66+
sid = "Enable IAM User Permissions"
67+
effect = "Allow"
68+
principals {
69+
type = "AWS"
70+
identifiers = ["*"]
71+
}
72+
actions = ["kms:*"]
73+
resources = ["*"]
74+
}
75+
}
76+
4477
module "redis" {
4578
source = "./../../"
4679
name = "redis"
@@ -49,14 +82,17 @@ module "redis" {
4982

5083
replication_enabled = true
5184
engine = "redis"
52-
engine_version = "6.2"
53-
parameter_group_name = "default.redis6.x"
85+
engine_version = "7.0"
86+
parameter_group_name = "default.redis7"
5487
port = 6379
5588
node_type = "cache.t2.micro"
89+
kms_key_id = module.kms_key.key_arn
5690
subnet_ids = module.subnets.public_subnet_id
5791
security_group_ids = [module.redis-sg.security_group_ids]
5892
availability_zones = ["eu-west-1a", "eu-west-1b"]
93+
automatic_failover_enabled = true
5994
auto_minor_version_upgrade = true
95+
multi_az_enabled = true #Specifies whether to enable Multi-AZ Support for the replication group. If true, automatic_failover_enabled must also be enabled
6096
num_cache_clusters = 2
6197
retention_in_days = 0
6298
snapshot_retention_limit = 7

0 commit comments

Comments
 (0)