Skip to content

Commit 9b859ff

Browse files
bmihaescuantonbabenko
authored andcommitted
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
1 parent 7a52ef6 commit 9b859ff

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ Sometimes it is handy to have public access to RDS instances (it is not recommen
165165
enable_dns_support = true
166166
```
167167

168+
## Public access to Redshift cluster
169+
170+
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:
171+
172+
```hcl
173+
enable_public_redshift = true # <= Default it will be placed into private subnet route table
174+
```
175+
168176
## Terraform version
169177

170178
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.
271279
| redshift\_subnet\_suffix | Suffix to append to redshift subnets name | string | `"redshift"` | no |
272280
| redshift\_subnet\_tags | Additional tags for the redshift subnets | map | `{}` | no |
273281
| redshift\_subnets | A list of redshift subnets | list | `[]` | no |
282+
| enable\_public\_redshift | Should be true if you want Redshift cluster to be placed into public subnet route table | string | `"false"` | no |
274283
| 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 |
275284
| secondary\_cidr\_blocks | List of secondary CIDR blocks to associate with the VPC to extend the IP Address pool | list | `[]` | no |
276285
| 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 |

main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,19 @@ resource "aws_route_table_association" "database" {
569569
}
570570

571571
resource "aws_route_table_association" "redshift" {
572-
count = "${var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"
572+
count = "${var.enable_public_redshift == false && var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"
573573

574574
subnet_id = "${element(aws_subnet.redshift.*.id, count.index)}"
575575
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))}"
576576
}
577577

578+
resource "aws_route_table_association" "redshift_public" {
579+
count = "${var.enable_public_redshift && var.create_vpc && length(var.redshift_subnets) > 0 ? length(var.redshift_subnets) : 0}"
580+
581+
subnet_id = "${element(aws_subnet.redshift.*.id, count.index)}"
582+
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))}"
583+
}
584+
578585
resource "aws_route_table_association" "elasticache" {
579586
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 ? length(var.elasticache_subnets) : 0}"
580587

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ variable "create_redshift_subnet_route_table" {
102102
default = false
103103
}
104104

105+
variable "enable_public_redshift" {
106+
description = "Controls if redshift should have public routing table"
107+
default = false
108+
}
109+
105110
variable "create_elasticache_subnet_route_table" {
106111
description = "Controls if separate route table for elasticache should be created"
107112
default = false

0 commit comments

Comments
 (0)