-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from silinternational/develop
Release 3.6.0 - Redis
- Loading branch information
Showing
10 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# aws/ecs/elasticache/redis - Create a Elasticache cluster of Redis servers | ||
This module is used to create an Elasticache cluster of Redis servers | ||
|
||
## What this does | ||
|
||
- Create Elasticache subnet group spanning all provided `var.subnet_ids`. | ||
- Create Elasticache cluster of Redis servers. | ||
|
||
## Required Inputs | ||
|
||
- `cluster_id` - ID/Name for Elasticache Cluster. Max 20 characters. | ||
- `security_group_ids` - List of security group IDs to place cluster in | ||
- `subnet_group_name` - Name of subnet group to create and place cluster in. | ||
- `subnet_ids` - List of subnet ids for subnet group. | ||
- `availability_zones` - List of availability zones to place cluster in. | ||
- `app_name` - Application name to be tagged to cluster as `app_name`. | ||
- `app_env` - Application environment to be tagged to cluster as `app_env`. | ||
|
||
### Optional Inputs | ||
|
||
- `node_type` - Instance node type. Default: `cache.t2.micro` | ||
- `port` - Redis port. Default: `6379` | ||
- `parameter_group_name` - Name of Redis parameter group to use. Default: `default.redisd1.4` | ||
- `engine_version` - Redis engine version. Default: `6.x`' | ||
|
||
## Outputs | ||
|
||
- `cache_nodes` - List of cache nodes. | ||
- `configuration_endpoint` - Redis configuration endpoint. | ||
- `cluster_address` - DNS name for cache clusters without port. | ||
|
||
## Usage Example | ||
|
||
```hcl | ||
module "redis" { | ||
source = "github.com/silinternational/terraform-modules//aws/elasticache/redis" | ||
cluster_id = "doorman-cache" | ||
security_group_ids = [module.vpc.vpc_default_sg_id] | ||
subnet_group_name = "doorman-cache-subnet" | ||
subnet_ids = module.vpc.private_subnet_ids | ||
availability_zones = module.vpc.aws_zones | ||
app_name = "doorman" | ||
app_env = "staging" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Create Elasticache subnet group | ||
*/ | ||
resource "aws_elasticache_subnet_group" "redis_subnet_group" { | ||
name = var.subnet_group_name | ||
subnet_ids = var.subnet_ids | ||
} | ||
|
||
/* | ||
* Create Cluster | ||
*/ | ||
resource "aws_elasticache_cluster" "redis" { | ||
cluster_id = replace(var.cluster_id, "/(.{0,20})(.*)/", "$1") // truncates to maximum of 20 characters | ||
engine = "redis" | ||
engine_version = var.engine_version | ||
node_type = var.node_type | ||
port = var.port | ||
num_cache_nodes = "1" | ||
parameter_group_name = var.parameter_group_name | ||
security_group_ids = var.security_group_ids | ||
subnet_group_name = aws_elasticache_subnet_group.redis_subnet_group.name | ||
|
||
tags = { | ||
app_name = var.app_name | ||
app_env = var.app_env | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Cluster outputs | ||
*/ | ||
output "cache_nodes" { | ||
value = aws_elasticache_cluster.redis.cache_nodes | ||
} | ||
|
||
output "configuration_endpoint" { | ||
value = aws_elasticache_cluster.redis.configuration_endpoint | ||
} | ||
|
||
output "cluster_address" { | ||
value = aws_elasticache_cluster.redis.cluster_address | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Required Variables | ||
*/ | ||
variable "cluster_id" { | ||
type = string | ||
} | ||
|
||
variable "security_group_ids" { | ||
type = list(string) | ||
} | ||
|
||
variable "subnet_group_name" { | ||
type = string | ||
} | ||
|
||
variable "subnet_ids" { | ||
type = list(string) | ||
} | ||
|
||
variable "availability_zones" { | ||
type = list(string) | ||
} | ||
|
||
variable "app_name" { | ||
type = string | ||
} | ||
|
||
variable "app_env" { | ||
type = string | ||
} | ||
|
||
/* | ||
* Optional Variables | ||
*/ | ||
variable "node_type" { | ||
type = string | ||
default = "cache.t2.micro" | ||
} | ||
|
||
variable "port" { | ||
type = string | ||
default = "6379" | ||
} | ||
|
||
variable "parameter_group_name" { | ||
type = string | ||
default = "default.redis6.x" | ||
} | ||
|
||
variable "engine_version" { | ||
default = "6.x" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
terraform { | ||
required_version = ">= 0.12" | ||
} |