diff --git a/.gitignore b/.gitignore index a4190a4..a0dd221 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ *.tfstate.backup # Module directory -.terraform/ - +.terraform .idea *.iml diff --git a/README.md b/README.md index fcea99a..56a804b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ -# tf_redis +# terraform-aws-elasticache-redis + +Terraform module to provision an [`ElastiCache`](https://aws.amazon.com/elasticache/) Redis Cluster -Terraform module to provision a ElastiCache Redis Cluster ## Usage Include this repository as a module in your existing terraform code: -``` +```hcl module "example_redis" { - source = "git::https://github.com/cloudposse/tf_redis.git?ref=tags/0.1.0" + source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=master" namespace = "general" name = "redis" stage = "prod" @@ -30,10 +31,11 @@ module "example_redis" { } ``` + ## Input -| Name | Default | Decription | -|:----------------------------:|:-------------------:|:------------------------------------------------------:| +| Name | Default | Description | +|:-----------------------------|:-------------------:|:-------------------------------------------------------| | namespace |global |Namespace | | stage |default |Stage | | name |redis |Name | @@ -46,7 +48,7 @@ module "example_redis" { | engine_version | 3.2.4 | Redis engine version | | port | 6379 | Redis port | | maintenance_window | wed:03:00-wed:04:00 | Maintenance window | -| notification_topic_arn | | Notificate topic arn | +| notification_topic_arn | | Notification topic arn | | alarm_cpu_threshold_percent | 75 | CPU threshold alarm level | | alarm_memory_threshold_bytes | 10000000 | Ram threshold alarm level | | alarm_actions | [] | Alarm action list | @@ -55,12 +57,17 @@ module "example_redis" { | availability_zones | [] | Availability zone ids | | zone_id | false | Route53 dns zone id | + ## Output -| Name | Decription | -|:-----------------:|:-----------------:| +| Name | Description | +|:------------------|:------------------| | id | Redis cluster id | | security_group_id | Security group id | | host | Redis host | | port | Redis port | + +## License + +Apache 2 License. See [`LICENSE`](LICENSE) for full details. diff --git a/main.tf b/main.tf index d45344e..471faf2 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,6 @@ # Define composite variables for resources module "label" { - source = "git::https://github.com/cloudposse/tf_label.git?ref=tags/0.2.0" + source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.2.1" namespace = "${var.namespace}" name = "${var.name}" stage = "${var.stage}" @@ -15,8 +15,9 @@ module "label" { resource "aws_security_group" "default" { vpc_id = "${var.vpc_id}" name = "${module.label.id}" + ingress { - from_port = "${var.port}" # Redis + from_port = "${var.port}" # Redis to_port = "${var.port}" protocol = "tcp" security_groups = ["${var.security_groups}"] @@ -29,7 +30,7 @@ resource "aws_security_group" "default" { cidr_blocks = ["0.0.0.0/0"] } - tags = "${module.label.tags}" + tags = "${module.label.tags}" } resource "aws_elasticache_subnet_group" "default" { @@ -56,7 +57,7 @@ resource "aws_elasticache_replication_group" "default" { maintenance_window = "${var.maintenance_window}" notification_topic_arn = "${var.notification_topic_arn}" - tags = "${module.label.tags}" + tags = "${module.label.tags}" } # @@ -72,15 +73,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" { period = "300" statistic = "Average" - threshold = "${var.alarm_cpu_threshold_percent}" + threshold = "${var.alarm_cpu_threshold_percent}" dimensions { CacheClusterId = "${module.label.id}" } - alarm_actions = ["${var.alarm_actions}"] - depends_on = ["aws_elasticache_replication_group.default"] - tags = "${module.label.tags}" + alarm_actions = ["${var.alarm_actions}"] + depends_on = ["aws_elasticache_replication_group.default"] + tags = "${module.label.tags}" } resource "aws_cloudwatch_metric_alarm" "cache_memory" { @@ -93,20 +94,19 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" { period = "60" statistic = "Average" - threshold = "${var.alarm_memory_threshold_bytes}" + threshold = "${var.alarm_memory_threshold_bytes}" dimensions { CacheClusterId = "${module.label.id}" } - alarm_actions = ["${var.alarm_actions}"] - depends_on = ["aws_elasticache_replication_group.default"] - tags = "${module.label.tags}" + alarm_actions = ["${var.alarm_actions}"] + depends_on = ["aws_elasticache_replication_group.default"] + tags = "${module.label.tags}" } - module "dns" { - source = "git::https://github.com/cloudposse/tf_hostname.git?ref=tags/0.1.0" + source = "git::https://github.com/cloudposse/terraform-aws-route53-cluster-hostname.git?ref=tags/0.1.1" namespace = "${var.namespace}" name = "${var.name}" stage = "${var.stage}" diff --git a/output.tf b/output.tf index f2b0e3e..2b64d6a 100644 --- a/output.tf +++ b/output.tf @@ -13,4 +13,3 @@ output "port" { output "host" { value = "${module.dns.hostname}" } -