Skip to content

Commit b96cbc9

Browse files
committed
chore: Updates from testing and validating upgrade guide
1 parent 6b63603 commit b96cbc9

File tree

7 files changed

+51
-62
lines changed

7 files changed

+51
-62
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module "redshift" {
2525
encrypted = true
2626
kms_key_arn = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
2727
28+
vpc_id = "vpc-1234556abcdef"
2829
enhanced_vpc_routing = true
2930
availability_zone_relocation_enabled = true
3031

docs/UPGRADE-7.0.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ Please consult the `examples` directory for reference example configurations. If
88
- AWS provider `v6.18` is now minimum supported version
99
- The ability for the module to create a random password has been removed in order to ensure passwords are not stored in plain text within the state file. Users must now provide their own password via the `master_password_wo` variable.
1010
- `master_password` is no longer supported and only the write-only equivalent is supported (`master_password_wo` and `master_password_wo_version`)
11+
- The variable(s) used to create access endpoints has changed from creating a single endpoint to n-number of endpoints
1112

1213
## Additional changes
1314

1415
### Added
1516

1617
- Support for `region` argument to specify the AWS region for the resources created if different from the provider region.
17-
- Support for creating security group
18+
- Support for creating a security group used by the cluster
1819

1920
### Modified
2021

@@ -23,7 +24,7 @@ Please consult the `examples` directory for reference example configurations. If
2324

2425
### Removed
2526

26-
-
27+
- Support for generating random passwords has been removed.
2728

2829
### Variable and output changes
2930

@@ -64,15 +65,18 @@ Please consult the `examples` directory for reference example configurations. If
6465

6566
4. Removed outputs:
6667

67-
-
68+
- `endpoint_access_address` -> see `endpoint_access` output
69+
- `endpoint_access_port` -> see `endpoint_access` output
70+
- `endpoint_access_id` -> see `endpoint_access` output
71+
- `endpoint_access_vpc_endpoint` -> see `endpoint_access` output
6872

6973
5. Renamed outputs:
7074

71-
-
75+
- None
7276

7377
6. Added outputs:
7478

75-
-
79+
- None
7680

7781
## Upgrade Migration
7882

@@ -121,9 +125,9 @@ module "redshift" {
121125
122126
# Endpoint access - only available when using the ra3.x type
123127
create_endpoint_access = true
124-
endpoint_name = "example-example"
125-
endpoint_subnet_group_name = aws_redshift_subnet_group.endpoint.id
126-
endpoint_vpc_security_group_ids = [module.security_group.security_group_id]
128+
endpoint_name = "example"
129+
endpoint_subnet_group_name = "example"
130+
endpoint_vpc_security_group_ids = ["sg-12345678"]
127131
}
128132
```
129133

@@ -136,6 +140,9 @@ module "redshift" {
136140
137141
# Only the affected attributes are shown
138142
143+
# Security group
144+
vpc_id = "vpc-1234556abcdef"
145+
139146
# Snapshot schedule
140147
snapshot_schedule = {
141148
identifier = "example"
@@ -180,14 +187,16 @@ module "redshift" {
180187
# Endpoint access - only available when using the ra3.x type
181188
endpoint_access = {
182189
example = {
183-
name = "example-example"
184-
subnet_group_name = aws_redshift_subnet_group.endpoint.id
185-
vpc_security_group_ids = [module.security_group.security_group_id]
190+
name = "example"
191+
subnet_group_name = "example"
192+
vpc_security_group_ids = ["sg-12345678"]
186193
}
187194
}
188195
}
189196
```
190197

191198
### State Move Commands
192199

193-
TBD
200+
```sh
201+
terraform state mv 'module.redshift.aws_redshift_endpoint_access.this[0]' 'module.redshift.aws_redshift_endpoint_access.this["example"]'
202+
```

examples/complete/main.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ locals {
3333
module "redshift" {
3434
source = "../../"
3535

36+
# Maintains backward compatibility
37+
parameter_group_family = "redshift-1.0"
38+
3639
cluster_identifier = local.name
3740
allow_version_upgrade = true
3841
node_type = "ra3.xlplus"
@@ -51,6 +54,7 @@ module "redshift" {
5154
# Only available when using the ra3.x type
5255
availability_zone_relocation_enabled = true
5356
enhanced_vpc_routing = true
57+
vpc_id = module.vpc.vpc_id
5458

5559
snapshot_copy = {
5660
destination_region = "us-east-1"
@@ -216,9 +220,13 @@ resource "aws_redshift_snapshot_copy_grant" "useast1" {
216220
module "with_cloudwatch_logging" {
217221
source = "../../"
218222

223+
# Maintains backward compatibility
224+
parameter_group_family = "redshift-1.0"
225+
219226
cluster_identifier = "${local.name}-with-cloudwatch-logging"
220-
node_type = "dc2.large"
227+
node_type = "ra3.large"
221228

229+
vpc_id = module.vpc.vpc_id
222230
subnet_ids = module.vpc.redshift_subnets
223231

224232
create_cloudwatch_log_group = true
@@ -238,9 +246,13 @@ module "with_cloudwatch_logging" {
238246
module "default" {
239247
source = "../../"
240248

249+
# Maintains backward compatibility
250+
parameter_group_family = "redshift-1.0"
251+
241252
cluster_identifier = "${local.name}-default"
242-
node_type = "dc2.large"
253+
node_type = "ra3.large"
243254

255+
vpc_id = module.vpc.vpc_id
244256
subnet_ids = module.vpc.redshift_subnets
245257

246258
tags = local.tags

examples/complete/outputs.tf

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ output "cluster_namespace_arn" {
115115
output "cluster_master_password" {
116116
description = "The Redshift cluster master password"
117117
value = module.redshift.cluster_master_password
118+
sensitive = true
118119
}
119120

120121
output "cluster_master_username" {
@@ -187,24 +188,9 @@ output "scheduled_action_iam_role_unique_id" {
187188
# Endpoint Access
188189
################################################################################
189190

190-
output "endpoint_access_address" {
191-
description = "The DNS address of the endpoint"
192-
value = module.redshift.endpoint_access_address
193-
}
194-
195-
output "endpoint_access_id" {
196-
description = "The Redshift-managed VPC endpoint name"
197-
value = module.redshift.endpoint_access_id
198-
}
199-
200-
output "endpoint_access_port" {
201-
description = "The port number on which the cluster accepts incoming connections"
202-
value = module.redshift.endpoint_access_port
203-
}
204-
205-
output "endpoint_access_vpc_endpoint" {
206-
description = "The connection endpoint for connecting to an Amazon Redshift cluster through the proxy. See details below"
207-
value = module.redshift.endpoint_access_vpc_endpoint
191+
output "endpoint_access" {
192+
description = "A map of access endpoints created and their attributes"
193+
value = module.redshift.endpoint_access
208194
}
209195

210196
################################################################################

main.tf

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ resource "aws_redshift_subnet_group" "this" {
125125
# Snapshot Schedule
126126
################################################################################
127127

128-
locals {
129-
snapshot_schedule_identifier = try(coalesce(var.snapshot_schedule.identifier, var.cluster_identifier))
130-
}
131-
132128
resource "aws_redshift_snapshot_schedule" "this" {
133129
count = var.create && var.snapshot_schedule != null ? 1 : 0
134130

@@ -137,8 +133,8 @@ resource "aws_redshift_snapshot_schedule" "this" {
137133
definitions = var.snapshot_schedule.definitions
138134
description = var.snapshot_schedule.description
139135
force_destroy = var.snapshot_schedule.force_destroy
140-
identifier = var.snapshot_schedule.use_prefix ? null : local.snapshot_schedule_identifier
141-
identifier_prefix = var.snapshot_schedule.use_prefix ? "${local.snapshot_schedule_identifier}-" : null
136+
identifier = var.snapshot_schedule.use_prefix ? null : try(coalesce(var.snapshot_schedule.identifier, var.cluster_identifier), "")
137+
identifier_prefix = var.snapshot_schedule.use_prefix ? "${try(coalesce(var.snapshot_schedule.identifier, var.cluster_identifier), "")}-" : null
142138

143139
tags = merge(var.tags, var.snapshot_schedule.tags)
144140
}
@@ -178,15 +174,15 @@ resource "aws_redshift_scheduled_action" "this" {
178174

179175
content {
180176
dynamic "pause_cluster" {
181-
for_each = each.value.pause_cluster != null ? [1] : []
177+
for_each = target_action.value.pause_cluster != null && target_action.value.pause_cluster ? [1] : []
182178

183179
content {
184180
cluster_identifier = aws_redshift_cluster.this[0].id
185181
}
186182
}
187183

188184
dynamic "resize_cluster" {
189-
for_each = each.value.resize_cluster != null ? [1] : []
185+
for_each = target_action.value.resize_cluster != null ? [target_action.value.resize_cluster] : []
190186

191187
content {
192188
classic = resize_cluster.value.classic
@@ -198,7 +194,7 @@ resource "aws_redshift_scheduled_action" "this" {
198194
}
199195

200196
dynamic "resume_cluster" {
201-
for_each = each.value.resume_cluster != null ? [each.value.resume_cluster] : []
197+
for_each = target_action.value.resume_cluster != null && target_action.value.resume_cluster ? [target_action.value.resume_cluster] : []
202198

203199
content {
204200
cluster_identifier = aws_redshift_cluster.this[0].id
@@ -317,7 +313,7 @@ resource "aws_redshift_authentication_profile" "this" {
317313

318314
region = var.region
319315

320-
authentication_profile_name = try(each.value.name, each.key)
316+
authentication_profile_name = try(coalesce(each.value.name, each.key))
321317
authentication_profile_content = jsonencode(each.value.content)
322318
}
323319

@@ -342,7 +338,7 @@ resource "aws_redshift_logging" "this" {
342338
################################################################################
343339

344340
resource "aws_cloudwatch_log_group" "this" {
345-
for_each = toset([for log in try(var.logging.log_exports, []) : log if var.create && var.create_cloudwatch_log_group])
341+
for_each = var.create && var.create_cloudwatch_log_group && var.logging != null ? toset([for log in try(var.logging.log_exports, []) : log]) : toset([])
346342

347343
region = var.region
348344

outputs.tf

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,9 @@ output "scheduled_action_iam_role_unique_id" {
193193
# Endpoint Access
194194
################################################################################
195195

196-
output "endpoint_access_address" {
197-
description = "The DNS address of the endpoint"
198-
value = try(aws_redshift_endpoint_access.this[0].address, null)
199-
}
200-
201-
output "endpoint_access_id" {
202-
description = "The Redshift-managed VPC endpoint name"
203-
value = try(aws_redshift_endpoint_access.this[0].id, null)
204-
}
205-
206-
output "endpoint_access_port" {
207-
description = "The port number on which the cluster accepts incoming connections"
208-
value = try(aws_redshift_endpoint_access.this[0].port, null)
209-
}
210-
211-
output "endpoint_access_vpc_endpoint" {
212-
description = "The connection endpoint for connecting to an Amazon Redshift cluster through the proxy. See details below"
213-
value = try(aws_redshift_endpoint_access.this[0].vpc_endpoint, null)
196+
output "endpoint_access" {
197+
description = "A map of access endpoints created and their attributes"
198+
value = aws_redshift_endpoint_access.this
214199
}
215200

216201
################################################################################

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ variable "logging" {
465465
type = object({
466466
bucket_name = optional(string)
467467
log_destination_type = optional(string)
468-
log_exports = optional(list(string))
468+
log_exports = optional(list(string), [])
469469
s3_key_prefix = optional(string)
470470
})
471471
default = null

0 commit comments

Comments
 (0)