Skip to content

Commit b4ce5a4

Browse files
author
Nikita Dugar
committed
initial commit
0 parents  commit b4ce5a4

File tree

20 files changed

+1034
-0
lines changed

20 files changed

+1034
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ignored files
2+
*.tfstate
3+
*.tfstate.backup
4+
.terraform
5+
.idea
6+
*.iml

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: git://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.12.0
4+
hooks:
5+
- id: terraform_fmt
6+
7+
- repo: https://github.com/pre-commit/pre-commit-hooks
8+
rev: v2.0.0
9+
hooks:
10+
- id: check-merge-conflict
11+
- id: trailing-whitespace
12+
- id: check-yaml
13+
- id: check-added-large-files

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Cloud Drove
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export GENIE_PATH ?= $(shell 'pwd')/../../../genie
2+
3+
include $(GENIE_PATH)/Makefile

README.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
<!-- This file was automatically generated by the `geine`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->
2+
3+
<p align="center"> <img src="https://user-images.githubusercontent.com/50652676/62349836-882fef80-b51e-11e9-99e3-7b974309c7e3.png" width="100" height="100"></p>
4+
5+
6+
<h1 align="center">
7+
Terraform AWS Elasticache
8+
</h1>
9+
10+
<p align="center" style="font-size: 1.2rem;">
11+
Terraform module to create Elasticache Cluster and replica for Redis and Memcache.
12+
</p>
13+
14+
<p align="center">
15+
16+
<a href="https://www.terraform.io">
17+
<img src="https://img.shields.io/badge/Terraform-v0.12-green" alt="Terraform">
18+
</a>
19+
<a href="LICENSE.md">
20+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="Licence">
21+
</a>
22+
23+
24+
</p>
25+
<p align="center">
26+
27+
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-aws-elasticache'>
28+
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
29+
</a>
30+
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+AWS+Elasticache&url=https://github.com/clouddrove/terraform-aws-elasticache'>
31+
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
32+
</a>
33+
<a href='https://twitter.com/intent/tweet/?text=Terraform+AWS+Elasticache&url=https://github.com/clouddrove/terraform-aws-elasticache'>
34+
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
35+
</a>
36+
37+
</p>
38+
<hr>
39+
40+
41+
We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
42+
43+
This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
44+
45+
We have [*fifty plus terraform modules*][terraform_modules]. A few of them are comepleted and are available for open source usage while a few others are in progress.
46+
47+
48+
49+
50+
## Prerequisites
51+
52+
This module has a few dependencies:
53+
54+
- [Terraform 0.12](https://learn.hashicorp.com/terraform/getting-started/install.html)
55+
- [Go](https://golang.org/doc/install)
56+
- [github.com/stretchr/testify/assert](https://github.com/stretchr/testify)
57+
- [github.com/gruntwork-io/terratest/modules/terraform](https://github.com/gruntwork-io/terratest)
58+
59+
60+
61+
62+
63+
64+
65+
## Examples
66+
67+
68+
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-elasticache/releases).
69+
70+
71+
Here are some examples of how you can use this module in your inventory structure:
72+
### Redis
73+
```hcl
74+
module "redis" {
75+
source = "git::https://github.com/clouddrove/terraform-aws-elasticache?ref=tags/0.12.0"
76+
name = "redis"
77+
application = "cd"
78+
environment = "test"
79+
label_order = ["environment", "name", "application"]
80+
engine = "redis"
81+
engine_version = "5.0.0"
82+
family = "redis5.0"
83+
port = 6379
84+
node_type = "cache.t2.micro"
85+
subnet_ids = ["subnet-xxxxxxx","subnet-xxxxxxx","subnet-xxxxxxx"]
86+
security_group_ids = ["sg-xxxxxxxxx"]
87+
availability_zones = ["eu-west-1a","eu-west-1b" ]
88+
auto_minor_version_upgrade = true
89+
number_cache_clusters = 2
90+
}
91+
```
92+
### Redis Cluster
93+
```hcl
94+
module "s3_bucket" {
95+
source = "git::https://github.com/clouddrove/terraform-aws-elasticache?ref=tags/0.12.0"
96+
name = "cluster"
97+
application = "cd"
98+
environment = "test"
99+
label_order = ["environment", "name", "application"]
100+
cluster_replication_enabled = true
101+
engine = "redis"
102+
engine_version = "5.0.0"
103+
family = "redis5.0"
104+
port = 6379
105+
node_type = "cache.t2.micro"
106+
subnet_ids = module.subnets.public_subnet_id
107+
security_group_ids = [module.redis-sg.security_group_ids]
108+
availability_zones = ["us-east-1a", "us-east-1b"]
109+
auto_minor_version_upgrade = true
110+
replicas_per_node_group = 2
111+
num_node_groups = 1
112+
automatic_failover_enabled = true
113+
}
114+
```
115+
### Memcache
116+
```hcl
117+
module "memcached" {
118+
source = "https://github.com/clouddrove/terraform-aws-s3?ref=tags/0.12.0"
119+
name = "memcached"
120+
application = "cd"
121+
environment = "test"
122+
label_order = ["environment", "name", "application"]
123+
124+
cluster_enabled = true
125+
engine = "memcached"
126+
engine_version = "1.5.10"
127+
family = "memcached1.5"
128+
az_mode = "cross-az"
129+
port = 11211
130+
node_type = "cache.t2.micro"
131+
num_cache_nodes = 2
132+
subnet_ids = ["subnet-xxxxxxx","subnet-xxxxxxx","subnet-xxxxxxx"]
133+
security_group_ids = ["sg-xxxxxxxxx"]
134+
availability_zones = ["eu-west-1a","eu-west-1b" ]
135+
}
136+
```
137+
138+
139+
140+
141+
142+
143+
## Inputs
144+
145+
| Name | Description | Type | Default | Required |
146+
|------|-------------|:----:|:-----:|:-----:|
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+
| engine | The name of the cache engine to be used for the clusters in this replication group. e.g. redis. | string | `` | no |
159+
| engine_version | The version number of the cache engine to be used for the cache clusters in this replication group. | string | `` | no |
160+
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
161+
| family | (Required) The family of the ElastiCache parameter group. | string | `` | no |
162+
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
163+
| maintenance_window | Maintenance window. | string | `sun:05:00-sun:06:00` | no |
164+
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
165+
| node_type | The compute and memory capacity of the nodes in the node group. | string | `` | no |
166+
| notification_topic_arn | An Amazon Resource Name (ARN) of an SNS topic to send ElastiCache notifications to. | string | `` | no |
167+
| 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 |
168+
| num_node_groups | Number of Shards (nodes). | string | `` | no |
169+
| 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 |
170+
| port | the port number on which each of the cache nodes will accept connections. | string | `` | no |
171+
| replicas_per_node_group | Replicas per Shard. | string | `` | no |
172+
| replication_enabled | (Redis only) Enabled or disabled replication_group for redis standalone instance. | bool | `false` | no |
173+
| replication_group_id | The replication group identifier This parameter is stored as a lowercase string. | string | `` | no |
174+
| security_group_ids | One or more VPC security groups associated with the cache cluster. | list | `<list>` | no |
175+
| security_group_names | A list of cache security group names to associate with this replication group. | string | `` | no |
176+
| 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 |
177+
| 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 |
178+
| 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 |
179+
| 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 |
180+
| subnet_ids | List of VPC Subnet IDs for the cache subnet group. | list | `<list>` | no |
181+
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
182+
| transit_encryption_enabled | Whether to enable encryption in transit. | string | `false` | no |
183+
184+
## Outputs
185+
186+
| Name | Description |
187+
|------|-------------|
188+
| id | Redis cluster id. |
189+
| port | Redis port. |
190+
| tags | A mapping of tags to assign to the resource. |
191+
192+
193+
194+
195+
## Testing
196+
In this module testing is performed with [terratest](https://github.com/gruntwork-io/terratest) and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a [GO environment](https://golang.org/doc/install) in your system.
197+
198+
You need to run the following command in the testing folder:
199+
```hcl
200+
go test -run Test
201+
```
202+
203+
204+
205+
## Feedback
206+
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-elasticache/issues), or feel free to drop us an email at [hello@clouddrove.com](mailto:hello@clouddrove.com).
207+
208+
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-elasticache)!
209+
210+
## About us
211+
212+
At [CloudDrove][website], we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.
213+
214+
<p align="center">We are <b> The Cloud Experts!</b></p>
215+
<hr />
216+
<p align="center">We ❤️ <a href="https://github.com/clouddrove">Open Source</a> and you can check out <a href="https://github.com/clouddrove">our other modules</a> to get help with your new Cloud ideas.</p>
217+
218+
[website]: https://clouddrove.com
219+
[github]: https://github.com/clouddrove
220+
[linkedin]: https://cpco.io/linkedin
221+
[twitter]: https://twitter.com/clouddrove/
222+
[email]: https://clouddrove.com/contact-us.html
223+
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=

README.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
#
3+
# This is the canonical configuration for the `README.md`
4+
# Run `make readme` to rebuild the `README.md`
5+
#
6+
7+
# Name of this project
8+
name: Terraform AWS Elasticache
9+
10+
# License of this project
11+
license: "MIT"
12+
13+
# Canonical GitHub repo
14+
github_repo: clouddrove/terraform-aws-elasticache
15+
16+
# Badges to display
17+
badges:
18+
- name: "Terraform"
19+
image: "https://img.shields.io/badge/Terraform-v0.12-green"
20+
url: "https://www.terraform.io"
21+
- name: "Licence"
22+
image: "https://img.shields.io/badge/License-MIT-blue.svg"
23+
url: "LICENSE.md"
24+
25+
# description of this project
26+
description: |-
27+
Terraform module to create Elasticache Cluster and replica for Redis and Memcache.
28+
29+
# extra content
30+
include:
31+
- "terraform.md"
32+
33+
# How to use this project
34+
usage : |-
35+
Here are some examples of how you can use this module in your inventory structure:
36+
### Redis
37+
```hcl
38+
module "redis" {
39+
source = "git::https://github.com/clouddrove/terraform-aws-elasticache?ref=tags/0.12.0"
40+
name = "redis"
41+
application = "cd"
42+
environment = "test"
43+
label_order = ["environment", "name", "application"]
44+
engine = "redis"
45+
engine_version = "5.0.0"
46+
family = "redis5.0"
47+
port = 6379
48+
node_type = "cache.t2.micro"
49+
subnet_ids = ["subnet-xxxxxxx","subnet-xxxxxxx","subnet-xxxxxxx"]
50+
security_group_ids = ["sg-xxxxxxxxx"]
51+
availability_zones = ["eu-west-1a","eu-west-1b" ]
52+
auto_minor_version_upgrade = true
53+
number_cache_clusters = 2
54+
}
55+
```
56+
### Redis Cluster
57+
```hcl
58+
module "s3_bucket" {
59+
source = "git::https://github.com/clouddrove/terraform-aws-elasticache?ref=tags/0.12.0"
60+
name = "cluster"
61+
application = "cd"
62+
environment = "test"
63+
label_order = ["environment", "name", "application"]
64+
cluster_replication_enabled = true
65+
engine = "redis"
66+
engine_version = "5.0.0"
67+
family = "redis5.0"
68+
port = 6379
69+
node_type = "cache.t2.micro"
70+
subnet_ids = module.subnets.public_subnet_id
71+
security_group_ids = [module.redis-sg.security_group_ids]
72+
availability_zones = ["us-east-1a", "us-east-1b"]
73+
auto_minor_version_upgrade = true
74+
replicas_per_node_group = 2
75+
num_node_groups = 1
76+
automatic_failover_enabled = true
77+
}
78+
```
79+
### Memcache
80+
```hcl
81+
module "memcached" {
82+
source = "https://github.com/clouddrove/terraform-aws-s3?ref=tags/0.12.0"
83+
name = "memcached"
84+
application = "cd"
85+
environment = "test"
86+
label_order = ["environment", "name", "application"]
87+
88+
cluster_enabled = true
89+
engine = "memcached"
90+
engine_version = "1.5.10"
91+
family = "memcached1.5"
92+
az_mode = "cross-az"
93+
port = 11211
94+
node_type = "cache.t2.micro"
95+
num_cache_nodes = 2
96+
subnet_ids = ["subnet-xxxxxxx","subnet-xxxxxxx","subnet-xxxxxxx"]
97+
security_group_ids = ["sg-xxxxxxxxx"]
98+
availability_zones = ["eu-west-1a","eu-west-1b" ]
99+
}
100+
```

_example/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Compiled files
2+
*.tfstate
3+
*.tfstate.backup
4+
5+
# Module directory
6+
.terraform
7+
.idea
8+
*.iml
9+
10+
**/.build-harness
11+
**/build-harness

0 commit comments

Comments
 (0)