Commit 945d6701 authored by Max Moon's avatar Max Moon Committed by Erik Osterman

Add auth_token argument (#23)

* add auth token

* fmt

* update readme properly

* add auth token generation to readme
parent 3e2762b0
<!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. --> <!-- This file was automatically generated by the `build-harness`. Make all changes to `README.yaml` and run `make readme` to rebuild this file. -->
[![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com) [![Cloud Posse](https://cloudposse.com/logo-300x69.svg)](https://cloudposse.com)
# terraform-aws-elasticache-redis [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-elasticache-redis.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-elasticache-redis) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-elasticache-redis.svg)](https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) # terraform-aws-elasticache-redis [![Build Status](https://travis-ci.org/cloudposse/terraform-aws-elasticache-redis.svg?branch=master)](https://travis-ci.org/cloudposse/terraform-aws-elasticache-redis) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-elasticache-redis.svg)](https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com)
...@@ -29,6 +30,12 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE). ...@@ -29,6 +30,12 @@ It's 100% Open Source and licensed under the [APACHE2](LICENSE).
Include this repository as a module in your existing terraform code: Include this repository as a module in your existing terraform code:
```hcl ```hcl
// Generate a random string for auth token, no special chars
resource "random_string" "auth_token" {
length = 64
special = false
}
module "example_redis" { module "example_redis" {
source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=master" source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=master"
namespace = "general" namespace = "general"
...@@ -37,12 +44,13 @@ module "example_redis" { ...@@ -37,12 +44,13 @@ module "example_redis" {
zone_id = "${var.route53_zone_id}" zone_id = "${var.route53_zone_id}"
security_groups = ["${var.security_group_id}"] security_groups = ["${var.security_group_id}"]
auth_token = "${random_string.auth_token.result}"
vpc_id = "${var.vpc_id}" vpc_id = "${var.vpc_id}"
subnets = "${var.private_subnets}" subnets = "${var.private_subnets}"
maintenance_window = "wed:03:00-wed:04:00" maintenance_window = "wed:03:00-wed:04:00"
cluster_size = "2" cluster_size = "2"
instance_type = "cache.t2.micro" instance_type = "cache.t2.micro"
engine_version = "3.2.4" engine_version = "4.0.10"
alarm_cpu_threshold_percent = "${var.cache_alarm_cpu_threshold_percent}" alarm_cpu_threshold_percent = "${var.cache_alarm_cpu_threshold_percent}"
alarm_memory_threshold_bytes = "${var.cache_alarm_memory_threshold_bytes}" alarm_memory_threshold_bytes = "${var.cache_alarm_memory_threshold_bytes}"
apply_immediately = "true" apply_immediately = "true"
...@@ -50,6 +58,10 @@ module "example_redis" { ...@@ -50,6 +58,10 @@ module "example_redis" {
automatic_failover = "false" automatic_failover = "false"
} }
output "auth_token" {
value = "${random_string.auth_token.result}"
}
``` ```
...@@ -65,8 +77,9 @@ Review the [complete example](examples/simple) to see how to use this module. ...@@ -65,8 +77,9 @@ Review the [complete example](examples/simple) to see how to use this module.
``` ```
Available targets: Available targets:
help This help screen help Help screen
help/all Display help for all targets help/all Display help for all targets
help/short This help short screen
lint Lint terraform code lint Lint terraform code
``` ```
...@@ -81,6 +94,7 @@ Available targets: ...@@ -81,6 +94,7 @@ Available targets:
| apply_immediately | Apply changes immediately | string | `true` | no | | apply_immediately | Apply changes immediately | string | `true` | no |
| at_rest_encryption_enabled | Enable encryption at rest | string | `false` | no | | at_rest_encryption_enabled | Enable encryption at rest | string | `false` | no |
| attributes | Additional attributes (_e.g._ "1") | list | `<list>` | no | | attributes | Additional attributes (_e.g._ "1") | list | `<list>` | no |
| auth_token | Auth token for password protecting redis, transit_encryption_enabled must be set to 'true'! Password must be longer than 16 chars | string | `` | no |
| automatic_failover | Automatic failover (Not available for T1/T2 instances) | string | `false` | no | | automatic_failover | Automatic failover (Not available for T1/T2 instances) | string | `false` | no |
| availability_zones | Availability zone ids | list | `<list>` | no | | availability_zones | Availability zone ids | list | `<list>` | no |
| cluster_size | Count of nodes in cluster | string | `1` | no | | cluster_size | Count of nodes in cluster | string | `1` | no |
...@@ -98,7 +112,7 @@ Available targets: ...@@ -98,7 +112,7 @@ Available targets:
| stage | Stage | string | `default` | no | | stage | Stage | string | `default` | no |
| subnets | AWS subnet ids | list | `<list>` | no | | subnets | AWS subnet ids | list | `<list>` | no |
| tags | Additional tags (_e.g._ map("BusinessUnit","ABC") | map | `<map>` | no | | tags | Additional tags (_e.g._ map("BusinessUnit","ABC") | map | `<map>` | no |
| transit_encryption_enabled | Enable TLS | string | `false` | no | | transit_encryption_enabled | Enable TLS | string | `true` | no |
| vpc_id | AWS VPC id | string | `REQUIRED` | no | | vpc_id | AWS VPC id | string | `REQUIRED` | no |
| zone_id | Route53 DNS Zone id | string | `false` | no | | zone_id | Route53 DNS Zone id | string | `false` | no |
......
...@@ -37,6 +37,12 @@ usage: |- ...@@ -37,6 +37,12 @@ usage: |-
Include this repository as a module in your existing terraform code: Include this repository as a module in your existing terraform code:
```hcl ```hcl
// Generate a random string for auth token, no special chars
resource "random_string" "auth_token" {
length = 64
special = false
}
module "example_redis" { module "example_redis" {
source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=master" source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=master"
namespace = "general" namespace = "general"
...@@ -45,12 +51,13 @@ usage: |- ...@@ -45,12 +51,13 @@ usage: |-
zone_id = "${var.route53_zone_id}" zone_id = "${var.route53_zone_id}"
security_groups = ["${var.security_group_id}"] security_groups = ["${var.security_group_id}"]
auth_token = "${random_string.auth_token.result}"
vpc_id = "${var.vpc_id}" vpc_id = "${var.vpc_id}"
subnets = "${var.private_subnets}" subnets = "${var.private_subnets}"
maintenance_window = "wed:03:00-wed:04:00" maintenance_window = "wed:03:00-wed:04:00"
cluster_size = "2" cluster_size = "2"
instance_type = "cache.t2.micro" instance_type = "cache.t2.micro"
engine_version = "3.2.4" engine_version = "4.0.10"
alarm_cpu_threshold_percent = "${var.cache_alarm_cpu_threshold_percent}" alarm_cpu_threshold_percent = "${var.cache_alarm_cpu_threshold_percent}"
alarm_memory_threshold_bytes = "${var.cache_alarm_memory_threshold_bytes}" alarm_memory_threshold_bytes = "${var.cache_alarm_memory_threshold_bytes}"
apply_immediately = "true" apply_immediately = "true"
...@@ -58,6 +65,10 @@ usage: |- ...@@ -58,6 +65,10 @@ usage: |-
automatic_failover = "false" automatic_failover = "false"
} }
output "auth_token" {
value = "${random_string.auth_token.result}"
}
``` ```
examples: |- examples: |-
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
``` ```
Available targets: Available targets:
help This help screen help Help screen
help/all Display help for all targets help/all Display help for all targets
help/short This help short screen
lint Lint terraform code lint Lint terraform code
``` ```
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
| apply_immediately | Apply changes immediately | string | `true` | no | | apply_immediately | Apply changes immediately | string | `true` | no |
| at_rest_encryption_enabled | Enable encryption at rest | string | `false` | no | | at_rest_encryption_enabled | Enable encryption at rest | string | `false` | no |
| attributes | Additional attributes (_e.g._ "1") | list | `<list>` | no | | attributes | Additional attributes (_e.g._ "1") | list | `<list>` | no |
| auth_token | Auth token for password protecting redis, transit_encryption_enabled must be set to 'true'! Password must be longer than 16 chars | string | `` | no |
| automatic_failover | Automatic failover (Not available for T1/T2 instances) | string | `false` | no | | automatic_failover | Automatic failover (Not available for T1/T2 instances) | string | `false` | no |
| availability_zones | Availability zone ids | list | `<list>` | no | | availability_zones | Availability zone ids | list | `<list>` | no |
| cluster_size | Count of nodes in cluster | string | `1` | no | | cluster_size | Count of nodes in cluster | string | `1` | no |
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
| stage | Stage | string | `default` | no | | stage | Stage | string | `default` | no |
| subnets | AWS subnet ids | list | `<list>` | no | | subnets | AWS subnet ids | list | `<list>` | no |
| tags | Additional tags (_e.g._ map("BusinessUnit","ABC") | map | `<map>` | no | | tags | Additional tags (_e.g._ map("BusinessUnit","ABC") | map | `<map>` | no |
| transit_encryption_enabled | Enable TLS | string | `false` | no | | transit_encryption_enabled | Enable TLS | string | `true` | no |
| vpc_id | AWS VPC id | string | `REQUIRED` | no | | vpc_id | AWS VPC id | string | `REQUIRED` | no |
| zone_id | Route53 DNS Zone id | string | `false` | no | | zone_id | Route53 DNS Zone id | string | `false` | no |
......
...@@ -49,6 +49,8 @@ resource "aws_elasticache_parameter_group" "default" { ...@@ -49,6 +49,8 @@ resource "aws_elasticache_parameter_group" "default" {
resource "aws_elasticache_replication_group" "default" { resource "aws_elasticache_replication_group" "default" {
count = "${var.enabled == "true" ? 1 : 0}" count = "${var.enabled == "true" ? 1 : 0}"
auth_token = "${var.auth_token}"
replication_group_id = "${module.label.id}" replication_group_id = "${module.label.id}"
replication_group_description = "${module.label.id}" replication_group_description = "${module.label.id}"
node_type = "${var.instance_type}" node_type = "${var.instance_type}"
......
...@@ -71,7 +71,7 @@ variable "at_rest_encryption_enabled" { ...@@ -71,7 +71,7 @@ variable "at_rest_encryption_enabled" {
} }
variable "transit_encryption_enabled" { variable "transit_encryption_enabled" {
default = "false" default = "true"
description = "Enable TLS" description = "Enable TLS"
} }
...@@ -135,3 +135,9 @@ variable "tags" { ...@@ -135,3 +135,9 @@ variable "tags" {
description = "Additional tags (_e.g._ map(\"BusinessUnit\",\"ABC\")" description = "Additional tags (_e.g._ map(\"BusinessUnit\",\"ABC\")"
default = {} default = {}
} }
variable "auth_token" {
type = "string"
description = "Auth token for password protecting redis, transit_encryption_enabled must be set to 'true'! Password must be longer than 16 chars"
default = ""
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment