Commit 9b859ff5 authored by bmihaescu's avatar bmihaescu Committed by Anton Babenko

Redshift public subnets (#222)

* add public subnet for redshift to enable access for kinesis

* fix redshift subnet group name

* fix redshift public association

* add public redshift to documentation

* fix doc typo

* update code after review
parent 7a52ef6e
......@@ -165,6 +165,14 @@ Sometimes it is handy to have public access to RDS instances (it is not recommen
enable_dns_support = true
```
## Public access to Redshift cluster
Sometimes it is handy to have public access to Redshift clusters (for example if you need to access it by Kinesis - VPC endpoint for Kinesis is not yet supported by Redshift) by specifying these arguments:
```hcl
enable_public_redshift = true # <= Default it will be placed into private subnet route table
```
## Terraform version
Terraform version 0.10.3 or newer is required for this module to work.
......@@ -271,6 +279,7 @@ Terraform version 0.10.3 or newer is required for this module to work.
| redshift\_subnet\_suffix | Suffix to append to redshift subnets name | string | `"redshift"` | no |
| redshift\_subnet\_tags | Additional tags for the redshift subnets | map | `{}` | no |
| redshift\_subnets | A list of redshift subnets | list | `[]` | no |
| enable\_public\_redshift | Should be true if you want Redshift cluster to be placed into public subnet route table | string | `"false"` | no |
| reuse\_nat\_ips | Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external_nat_ip_ids' variable | string | `"false"` | no |
| secondary\_cidr\_blocks | List of secondary CIDR blocks to associate with the VPC to extend the IP Address pool | list | `[]` | no |
| single\_nat\_gateway | Should be true if you want to provision a single shared NAT Gateway across all of your private networks | string | `"false"` | no |
......
......@@ -569,12 +569,19 @@ resource "aws_route_table_association" "database" {
}
resource "aws_route_table_association" "redshift" {
count = "${var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"
count = "${var.enable_public_redshift == false && var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"
subnet_id = "${element(aws_subnet.redshift.*.id, count.index)}"
route_table_id = "${element(coalescelist(aws_route_table.redshift.*.id, aws_route_table.private.*.id), (var.single_nat_gateway || var.create_redshift_subnet_route_table ? 0 : count.index))}"
}
resource "aws_route_table_association" "redshift_public" {
count = "${var.enable_public_redshift && var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"
subnet_id = "${element(aws_subnet.redshift.*.id, count.index)}"
route_table_id = "${element(coalescelist(aws_route_table.redshift.*.id, aws_route_table.public.*.id), (var.single_nat_gateway || var.create_redshift_subnet_route_table ? 0 : count.index))}"
}
resource "aws_route_table_association" "elasticache" {
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 ? length(var.elasticache_subnets) : 0}"
......
......@@ -102,6 +102,11 @@ variable "create_redshift_subnet_route_table" {
default = false
}
variable "enable_public_redshift" {
description = "Controls if redshift should have public routing table"
default = false
}
variable "create_elasticache_subnet_route_table" {
description = "Controls if separate route table for elasticache should be created"
default = false
......
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