Skip to content

Commit 7295372

Browse files
committed
add kms for encryption
1 parent a27ad80 commit 7295372

File tree

5 files changed

+65
-48
lines changed

5 files changed

+65
-48
lines changed

.pre-commit-config.yaml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.12.0
3+
rev: v1.30.0
44
hooks:
5-
- id: terraform_fmt
5+
- id: terraform_fmt
6+
- id: terraform_tflint
67

78
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v2.0.0
9+
rev: v3.1.0
910
hooks:
1011
- id: check-merge-conflict
1112
- id: trailing-whitespace
1213
- id: check-yaml
13-
- id: check-added-large-files
14+
- id: check-added-large-files

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Cloud Drove
3+
Copyright (c) 2020 Cloud Drove
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+43-41
Original file line numberDiff line numberDiff line change
@@ -144,54 +144,56 @@ Here are some examples of how you can use this module in your inventory structur
144144

145145
| Name | Description | Type | Default | Required |
146146
|------|-------------|:----:|:-----:|:-----:|
147-
| application | Application (e.g. `cd` or `clouddrove`). | string | `` | no |
148-
| apply_immediately | Specifies whether any modifications are applied immediately, or during the next maintenance window. Default is false. | string | `false` | no |
149-
| at_rest_encryption_enabled | Enable encryption at rest. | string | `false` | no |
150-
| attributes | Additional attributes (e.g. `1`). | list | `<list>` | no |
151-
| auth_token | The password used to access a password protected server. Can be specified only if transit_encryption_enabled = true. | string | `` | no |
152-
| auto_minor_version_upgrade | Specifies whether a minor engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Defaults to true. | string | `true` | no |
153-
| automatic_failover_enabled | Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. If true, Multi-AZ is enabled for this replication group. If false, Multi-AZ is disabled for this replication group. Must be enabled for Redis (cluster mode enabled) replication groups. Defaults to false. | string | `false` | no |
154-
| availability_zones | A list of EC2 availability zones in which the replication group's cache clusters will be created. The order of the availability zones in the list is not important. | list(string) | - | yes |
155-
| az_mode | (Memcached only) Specifies whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. Valid values for this parameter are single-az or cross-az, default is single-az. If you want to choose cross-az, num_cache_nodes must be greater than 1. | string | `single-az` | no |
156-
| cluster_enabled | (Memcache only) Enabled or disabled cluster. | bool | `false` | no |
157-
| cluster_replication_enabled | (Redis only) Enabled or disabled replication_group for redis cluster. | bool | `false` | no |
158-
| description | Description for the cache subnet group. Defaults to `Managed by Terraform`. | string | `Managed by Terraform` | no |
159-
| enable | Enable or disable of elasticache | bool | `true` | no |
160-
| engine | The name of the cache engine to be used for the clusters in this replication group. e.g. redis. | string | `` | no |
161-
| engine_version | The version number of the cache engine to be used for the cache clusters in this replication group. | string | `` | no |
162-
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
163-
| family | (Required) The family of the ElastiCache parameter group. | string | `` | no |
164-
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
165-
| maintenance_window | Maintenance window. | string | `sun:05:00-sun:06:00` | no |
166-
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `anmol@clouddrove.com` | no |
167-
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
168-
| node_type | The compute and memory capacity of the nodes in the node group. | string | `` | no |
169-
| notification_topic_arn | An Amazon Resource Name (ARN) of an SNS topic to send ElastiCache notifications to. | string | `` | no |
170-
| num_cache_nodes | (Required unless replication_group_id is provided) The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcache, this value must be between 1 and 20. If this number is reduced on subsequent runs, the highest numbered nodes will be removed. | string | `1` | no |
171-
| num_node_groups | Number of Shards (nodes). | string | `` | no |
172-
| number_cache_clusters | (Required for Cluster Mode Disabled) The number of cache clusters (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications. | string | `` | no |
173-
| port | the port number on which each of the cache nodes will accept connections. | string | `` | no |
174-
| replicas_per_node_group | Replicas per Shard. | string | `` | no |
175-
| replication_enabled | (Redis only) Enabled or disabled replication_group for redis standalone instance. | bool | `false` | no |
176-
| replication_group_id | The replication group identifier This parameter is stored as a lowercase string. | string | `` | no |
177-
| security_group_ids | One or more VPC security groups associated with the cache cluster. | list | `<list>` | no |
178-
| security_group_names | A list of cache security group names to associate with this replication group. | string | `` | no |
179-
| snapshot_arns | A single-element string list containing an Amazon Resource Name (ARN) of a Redis RDB snapshot file stored in Amazon S3. | string | `` | no |
180-
| snapshot_name | The name of a snapshot from which to restore data into the new node group. Changing the snapshot_name forces a new resource. | string | `` | no |
181-
| snapshot_retention_limit | (Redis only) The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot_retention_limit is not supported on cache.t1.micro or cache.t2.* cache nodes. | string | `0` | no |
182-
| snapshot_window | (Redis only) The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum snapshot window is a 60 minute period. | string | `` | no |
183-
| subnet_ids | List of VPC Subnet IDs for the cache subnet group. | list | `<list>` | no |
184-
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
185-
| transit_encryption_enabled | Whether to enable encryption in transit. | string | `false` | no |
147+
| application | Application \(e.g. `cd` or `clouddrove`\). | string | `""` | no |
148+
| apply\_immediately | Specifies whether any modifications are applied immediately, or during the next maintenance window. Default is false. | string | `"false"` | no |
149+
| at\_rest\_encryption\_enabled | Enable encryption at rest. | string | `"false"` | no |
150+
| attributes | Additional attributes \(e.g. `1`\). | list | `<list>` | no |
151+
| auth\_token | The password used to access a password protected server. Can be specified only if transit\_encryption\_enabled = true. | string | `""` | no |
152+
| auto\_minor\_version\_upgrade | Specifies whether a minor engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Defaults to true. | string | `"true"` | no |
153+
| automatic\_failover\_enabled | Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. If true, Multi-AZ is enabled for this replication group. If false, Multi-AZ is disabled for this replication group. Must be enabled for Redis \(cluster mode enabled\) replication groups. Defaults to false. | string | `"false"` | no |
154+
| availability\_zones | A list of EC2 availability zones in which the replication group's cache clusters will be created. The order of the availability zones in the list is not important. | list(string) | n/a | yes |
155+
| az\_mode | \(Memcached only\) Specifies whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. Valid values for this parameter are single-az or cross-az, default is single-az. If you want to choose cross-az, num\_cache\_nodes must be greater than 1. | string | `"single-az"` | no |
156+
| cluster\_enabled | \(Memcache only\) Enabled or disabled cluster. | bool | `"false"` | no |
157+
| cluster\_replication\_enabled | \(Redis only\) Enabled or disabled replication\_group for redis cluster. | bool | `"false"` | no |
158+
| description | Description for the cache subnet group. Defaults to `Managed by Terraform`. | string | `"Managed by Terraform"` | no |
159+
| enable | Enable or disable of elasticache | bool | `"true"` | no |
160+
| engine | The name of the cache engine to be used for the clusters in this replication group. e.g. redis. | string | `""` | no |
161+
| engine\_version | The version number of the cache engine to be used for the cache clusters in this replication group. | string | `""` | no |
162+
| environment | Environment \(e.g. `prod`, `dev`, `staging`\). | string | `""` | no |
163+
| family | \(Required\) The family of the ElastiCache parameter group. | string | `""` | no |
164+
| kms\_key\_id | The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if at\_rest\_encryption\_enabled = true. | string | `""` | no |
165+
| label\_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
166+
| maintenance\_window | Maintenance window. | string | `"sun:05:00-sun:06:00"` | no |
167+
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `"anmol@clouddrove.com"` | no |
168+
| name | Name \(e.g. `app` or `cluster`\). | string | `""` | no |
169+
| node\_type | The compute and memory capacity of the nodes in the node group. | string | `"cache.t2.small"` | no |
170+
| notification\_topic\_arn | An Amazon Resource Name \(ARN\) of an SNS topic to send ElastiCache notifications to. | string | `""` | no |
171+
| num\_cache\_nodes | \(Required unless replication\_group\_id is provided\) The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcache, this value must be between 1 and 20. If this number is reduced on subsequent runs, the highest numbered nodes will be removed. | string | `"1"` | no |
172+
| num\_node\_groups | Number of Shards \(nodes\). | string | `""` | no |
173+
| number\_cache\_clusters | \(Required for Cluster Mode Disabled\) The number of cache clusters \(primary and replicas\) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications. | string | `""` | no |
174+
| parameter\_group\_name | The name of the parameter group to associate with this replication group. If this argument is omitted, the default cache parameter group for the specified engine is used. | string | `""` | no |
175+
| port | the port number on which each of the cache nodes will accept connections. | string | `""` | no |
176+
| replicas\_per\_node\_group | Replicas per Shard. | string | `""` | no |
177+
| replication\_enabled | \(Redis only\) Enabled or disabled replication\_group for redis standalone instance. | bool | `"false"` | no |
178+
| replication\_group\_id | The replication group identifier This parameter is stored as a lowercase string. | string | `""` | no |
179+
| security\_group\_ids | One or more VPC security groups associated with the cache cluster. | list | `<list>` | no |
180+
| security\_group\_names | A list of cache security group names to associate with this replication group. | string | `""` | no |
181+
| snapshot\_arns | A single-element string list containing an Amazon Resource Name \(ARN\) of a Redis RDB snapshot file stored in Amazon S3. | string | `""` | no |
182+
| snapshot\_name | The name of a snapshot from which to restore data into the new node group. Changing the snapshot\_name forces a new resource. | string | `""` | no |
183+
| snapshot\_retention\_limit | \(Redis only\) The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero \(0\), backups are turned off. Please note that setting a snapshot\_retention\_limit is not supported on cache.t1.micro or cache.t2.\* cache nodes. | string | `"0"` | no |
184+
| snapshot\_window | \(Redis only\) The daily time range \(in UTC\) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum snapshot window is a 60 minute period. | string | `""` | no |
185+
| subnet\_ids | List of VPC Subnet IDs for the cache subnet group. | list | `<list>` | no |
186+
| tags | Additional tags \(e.g. map\(`BusinessUnit`,`XYZ`\). | map | `<map>` | no |
187+
| transit\_encryption\_enabled | Whether to enable encryption in transit. | string | `"false"` | no |
186188

187189
## Outputs
188190

189191
| Name | Description |
190192
|------|-------------|
191193
| id | Redis cluster id. |
192-
| memcached_endpoint_address | Memcached endpoint address. |
194+
| memcached\_endpoint | Memcached endpoint address. |
193195
| port | Redis port. |
194-
| redis_endpoint | Redis endpoint address. |
196+
| redis\_endpoint | Redis endpoint address. |
195197
| tags | A mapping of tags to assign to the resource. |
196198

197199

main.tf

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
module "labels" {
1111
source = "git::https://github.com/clouddrove/terraform-labels.git?ref=tags/0.12.0"
1212

13+
enabled = var.enable
1314
name = var.name
1415
application = var.application
1516
environment = var.environment
@@ -54,6 +55,7 @@ resource "aws_elasticache_replication_group" "default" {
5455
at_rest_encryption_enabled = var.at_rest_encryption_enabled
5556
transit_encryption_enabled = var.transit_encryption_enabled
5657
auth_token = var.auth_token
58+
kms_key_id = var.kms_key_id
5759
tags = module.labels.tags
5860
}
5961

@@ -84,6 +86,7 @@ resource "aws_elasticache_replication_group" "cluster" {
8486
at_rest_encryption_enabled = var.at_rest_encryption_enabled
8587
transit_encryption_enabled = var.transit_encryption_enabled
8688
auth_token = var.auth_token
89+
kms_key_id = var.kms_key_id
8790
tags = module.labels.tags
8891
cluster_mode {
8992
replicas_per_node_group = var.replicas_per_node_group #Replicas per Shard
@@ -101,7 +104,7 @@ resource "aws_elasticache_cluster" "default" {
101104
port = var.port
102105
num_cache_nodes = var.num_cache_nodes
103106
az_mode = var.az_mode
104-
parameter_group_name = "default.memcached1.5"
107+
parameter_group_name = var.parameter_group_name
105108
node_type = var.node_type
106109
subnet_group_name = join("", aws_elasticache_subnet_group.default.*.name)
107110
security_group_ids = var.security_group_ids

variables.tf

+12-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ variable "port" {
7676
}
7777

7878
variable "node_type" {
79-
default = ""
79+
default = "cache.t2.small"
8080
description = "The compute and memory capacity of the nodes in the node group."
8181
}
8282

@@ -211,3 +211,14 @@ variable "num_node_groups" {
211211
default = ""
212212
description = "Number of Shards (nodes)."
213213
}
214+
215+
variable "kms_key_id" {
216+
default = ""
217+
description = "The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if at_rest_encryption_enabled = true."
218+
}
219+
220+
variable "parameter_group_name" {
221+
type = string
222+
default = ""
223+
description = "The name of the parameter group to associate with this replication group. If this argument is omitted, the default cache parameter group for the specified engine is used."
224+
}

0 commit comments

Comments
 (0)