Skip to content

Commit b2f936d

Browse files
committed
initial
0 parents  commit b2f936d

File tree

5 files changed

+179
-0
lines changed

5 files changed

+179
-0
lines changed

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016 Turner
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

main.tf

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#
2+
# Security group resources
3+
#
4+
5+
resource "aws_security_group" "redis" {
6+
vpc_id = "${var.vpc_id}"
7+
8+
tags {
9+
name = "${var.tag_name}"
10+
description = "${var.tag_description}"
11+
environment = "${var.tag_environment}"
12+
creator = "${var.tag_creator}"
13+
customer = "${var.tag_customer}"
14+
owner = "${var.tag_owner}"
15+
product = "${var.tag_product}"
16+
costcenter = "${var.tag_costcenter}"
17+
}
18+
}
19+
20+
#
21+
# ElastiCache resources
22+
#
23+
24+
resource "aws_elasticache_subnet_group" "default" {
25+
name = "subnet-group-${var.tag_customer}-${var.tag_product}-${var.tag_environment}"
26+
description = "Private subnets for the ElastiCache instances: ${var.tag_customer} ${var.tag_product} ${var.tag_environment}"
27+
subnet_ids = ["${split(",", var.private_subnet_ids)}"]
28+
}
29+
30+
resource "aws_elasticache_cluster" "redis" {
31+
cluster_id = "${var.tag_customer}-${var.tag_product}-${var.tag_environment}"
32+
engine = "redis"
33+
engine_version = "${var.engine_version}"
34+
maintenance_window = "${var.maintenance_window}"
35+
node_type = "${var.instance_type}"
36+
num_cache_nodes = "1"
37+
parameter_group_name = "default.redis2.8"
38+
port = "6379"
39+
subnet_group_name = "${aws_elasticache_subnet_group.default.name}"
40+
security_group_ids = ["${aws_security_group.redis.id}"]
41+
42+
tags {
43+
name = "${var.tag_name}"
44+
description = "${var.tag_description}"
45+
environment = "${var.tag_environment}"
46+
creator = "${var.tag_creator}"
47+
customer = "${var.tag_customer}"
48+
owner = "${var.tag_owner}"
49+
product = "${var.tag_product}"
50+
costcenter = "${var.tag_costcenter}"
51+
}
52+
}
53+
54+
#
55+
# todo: add CloudWatch resources
56+
#

outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "cache_security_group_id" {
2+
value = "${aws_security_group.redis.id}"
3+
}
4+
5+
output "hostname" {
6+
value = "${aws_elasticache_cluster.redis.cache_nodes.0.address}"
7+
}
8+
9+
output "port" {
10+
value = "${aws_elasticache_cluster.redis.cache_nodes.0.port}"
11+
}
12+
13+
output "endpoint" {
14+
value = "${join(":", aws_elasticache_cluster.redis.cache_nodes.0.address, aws_elasticache_cluster.redis.cache_nodes.0.port)}"
15+
}

readme.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# terraform-aws-elasticache-redis
2+
3+
A Terraform module to create an Amazon Web Services (AWS) Redis ElastiCache cluster.
4+
5+
### Usage
6+
7+
```terraform
8+
module "elasticache_redis" {
9+
source = "github.com/jritsema/terraform-aws-elasticache-redis"
10+
11+
vpc_id = "vpc-20f74844"
12+
private_subnet_ids = "subnet-4a887f3c,subnet-76dae35d"
13+
14+
engine_version = "2.8.24"
15+
instance_type = "cache.m3.medium"
16+
maintenance_window = "sun:05:00-sun:06:00"
17+
18+
tag_name = "redis"
19+
tag_description = "redis cluster for development"
20+
tag_creator = "creator"
21+
tag_product = "product"
22+
tag_customer = "customer"
23+
tag_owner = "owner"
24+
tag_environment = "dev"
25+
tag_costcenter = "TBD"
26+
}
27+
```
28+
29+
### Variables
30+
31+
- `vpc_id` - ID of VPC meant to house the cache
32+
- `private_subnet_ids` - Comma delimited list of private subnet IDs
33+
- `engine_version` - Cache engine version (default: `2.8.24`)
34+
- `instance_type` - Instance type for cache instance (default: `cache.m3.medium`)
35+
- `maintenance_window` - 60 minute time window to reserve for maintenance
36+
(default: `sun:05:00-sun:06:00`)
37+
- `tag_name`
38+
- `tag_description`
39+
- `tag_creator`
40+
- `tag_product`
41+
- `tag_customer`
42+
- `tag_owner`
43+
- `tag_environment`
44+
- `tag_costcenter`
45+
46+
### Outputs
47+
48+
- `cache_security_group_id` - Security group ID of the cache cluster
49+
- `hostname` - Public DNS name of cache node
50+
- `port` - Port of cache instance
51+
- `endpoint` - Public DNS name and port separated by a `:`

variables.tf

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
variable "vpc_id" {
2+
}
3+
4+
variable "private_subnet_ids" {
5+
}
6+
7+
variable "engine_version" {
8+
default = "2.8.24"
9+
}
10+
11+
variable "instance_type" {
12+
default = "cache.m3.medium"
13+
}
14+
15+
variable "maintenance_window" {
16+
# SUN 01:00AM-02:00AM ET
17+
default = "sun:05:00-sun:06:00"
18+
}
19+
20+
# tags
21+
22+
variable "tag_name" {
23+
}
24+
25+
variable "tag_description" {
26+
}
27+
28+
variable "tag_environment" {
29+
}
30+
31+
variable "tag_creator" {
32+
}
33+
34+
variable "tag_customer" {
35+
}
36+
37+
variable "tag_owner" {
38+
}
39+
40+
variable "tag_product" {
41+
}
42+
43+
variable "tag_costcenter" {
44+
}

0 commit comments

Comments
 (0)