Skip to content

Commit 3826756

Browse files
committed
feat: Consolidate variables under top level variables
1 parent c1c3f92 commit 3826756

File tree

6 files changed

+192
-118
lines changed

6 files changed

+192
-118
lines changed

README.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ module "redshift" {
1515
node_type = "ra3.xlplus"
1616
number_of_nodes = 3
1717
18-
database_name = "mydb"
19-
master_username = "mydbuser"
20-
create_random_password = false
21-
master_password = "MySecretPassw0rd1!" # Do better!
18+
database_name = "mydb"
19+
master_username = "mydbuser"
20+
21+
manage_master_password = true
22+
manage_master_password_rotation = true
23+
master_password_rotation_schedule_expression = "rate(90 days)"
2224
2325
encrypted = true
2426
kms_key_arn = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
2527
26-
enhanced_vpc_routing = true
27-
vpc_security_group_ids = ["sg-12345678"]
28-
subnet_ids = ["subnet-123456", "subnet-654321"]
29-
28+
enhanced_vpc_routing = true
3029
availability_zone_relocation_enabled = true
3130
3231
snapshot_copy = {
@@ -79,17 +78,19 @@ module "redshift" {
7978
# Subnet group
8079
subnet_group_name = "example-custom"
8180
subnet_group_description = "Custom subnet group for example cluster"
81+
subnet_ids = ["subnet-123456", "subnet-654321"]
8282
subnet_group_tags = {
8383
Additional = "CustomSubnetGroup"
8484
}
8585
8686
# Snapshot schedule
87-
create_snapshot_schedule = true
88-
snapshot_schedule_identifier = local.name
89-
use_snapshot_identifier_prefix = true
90-
snapshot_schedule_description = "Example snapshot schedule"
91-
snapshot_schedule_definitions = ["rate(12 hours)"]
92-
snapshot_schedule_force_destroy = true
87+
snapshot_schedule = {
88+
identifier = "example"
89+
use_prefix = true
90+
description = "Example snapshot schedule"
91+
definitions = ["rate(12 hours)"]
92+
force_destroy = true
93+
}
9394
9495
# Scheduled actions
9596
create_scheduled_action_iam_role = true
@@ -98,30 +99,39 @@ module "redshift" {
9899
name = "example-pause"
99100
description = "Pause cluster every night"
100101
schedule = "cron(0 22 * * ? *)"
101-
pause_cluster = true
102+
target_action = {
103+
pause_cluster = true
104+
}
102105
}
103106
resize = {
104107
name = "example-resize"
105108
description = "Resize cluster (demo only)"
106109
schedule = "cron(00 13 * * ? *)"
107-
resize_cluster = {
108-
node_type = "ds2.xlarge"
109-
number_of_nodes = 5
110+
target_action = {
111+
resize_cluster = {
112+
node_type = "ds2.xlarge"
113+
number_of_nodes = 5
114+
}
110115
}
111116
}
112117
resume = {
113118
name = "example-resume"
114119
description = "Resume cluster every morning"
115120
schedule = "cron(0 12 * * ? *)"
116-
resume_cluster = true
121+
target_action = {
122+
resume_cluster = true
123+
}
117124
}
118125
}
119126
120127
# Endpoint access
121-
create_endpoint_access = true
122-
endpoint_name = "example-example"
123-
endpoint_subnet_group_name = "example-subnet-group"
124-
endpoint_vpc_security_group_ids = ["sg-12345678"]
128+
endpoint_access = {
129+
example = {
130+
name = "example-example"
131+
subnet_group_name = "example-subnet-group"
132+
vpc_security_group_ids = ["sg-12345678"]
133+
}
134+
}
125135
126136
# Usage limits
127137
usage_limits = {
@@ -239,7 +249,6 @@ No modules.
239249
| <a name="input_create_parameter_group"></a> [create\_parameter\_group](#input\_create\_parameter\_group) | Determines whether to create a parameter group or use existing | `bool` | `true` | no |
240250
| <a name="input_create_scheduled_action_iam_role"></a> [create\_scheduled\_action\_iam\_role](#input\_create\_scheduled\_action\_iam\_role) | Determines whether a scheduled action IAM role is created | `bool` | `false` | no |
241251
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Determines whether to create security group for Redshift cluster | `bool` | `true` | no |
242-
| <a name="input_create_snapshot_schedule"></a> [create\_snapshot\_schedule](#input\_create\_snapshot\_schedule) | Determines whether to create a snapshot schedule | `bool` | `false` | no |
243252
| <a name="input_create_subnet_group"></a> [create\_subnet\_group](#input\_create\_subnet\_group) | Determines whether to create a subnet group or use existing | `bool` | `true` | no |
244253
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | The name of the first database to be created when the cluster is created. If you do not provide a name, Amazon Redshift will create a default database called `dev` | `string` | `null` | no |
245254
| <a name="input_default_iam_role_arn"></a> [default\_iam\_role\_arn](#input\_default\_iam\_role\_arn) | The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created | `string` | `null` | no |
@@ -281,7 +290,7 @@ No modules.
281290
| <a name="input_preferred_maintenance_window"></a> [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range (in UTC) during which automated cluster maintenance can occur. Format: `ddd:hh24:mi-ddd:hh24:mi` | `string` | `"sat:10:00-sat:10:30"` | no |
282291
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | If true, the cluster can be accessed from a public network | `bool` | `false` | no |
283292
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the Region set in the provider configuration | `string` | `null` | no |
284-
| <a name="input_scheduled_actions"></a> [scheduled\_actions](#input\_scheduled\_actions) | Map of scheduled action definitions to create | <pre>map(object({<br/> name = optional(string) # Will fall back to key if not set<br/> description = optional(string)<br/> enable = optional(bool)<br/> start_time = optional(string)<br/> end_time = optional(string)<br/> schedule = string<br/> iam_role = optional(string)<br/> target_action = object({<br/> pause_cluster = optional(object({}))<br/> resize_cluster = optional(object({<br/> classic = optional(bool)<br/> cluster_type = optional(string)<br/> node_type = optional(string)<br/> number_of_nodes = optional(number)<br/> }))<br/> resume_cluster = optional(object({}))<br/> })<br/> }))</pre> | `{}` | no |
293+
| <a name="input_scheduled_actions"></a> [scheduled\_actions](#input\_scheduled\_actions) | Map of scheduled action definitions to create | <pre>map(object({<br/> name = optional(string) # Will fall back to key if not set<br/> description = optional(string)<br/> enable = optional(bool)<br/> start_time = optional(string)<br/> end_time = optional(string)<br/> schedule = string<br/> iam_role = optional(string)<br/> target_action = object({<br/> pause_cluster = optional(bool, false)<br/> resize_cluster = optional(object({<br/> classic = optional(bool)<br/> cluster_type = optional(string)<br/> node_type = optional(string)<br/> number_of_nodes = optional(number)<br/> }))<br/> resume_cluster = optional(bool, false)<br/> })<br/> }))</pre> | `{}` | no |
285294
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The description of the security group. If value is set to empty string it will contain cluster name in the description | `string` | `null` | no |
286295
| <a name="input_security_group_egress_rules"></a> [security\_group\_egress\_rules](#input\_security\_group\_egress\_rules) | Map of security group egress rules to add to the security group created | <pre>map(object({<br/> name = optional(string)<br/><br/> cidr_ipv4 = optional(string)<br/> cidr_ipv6 = optional(string)<br/> description = optional(string)<br/> from_port = optional(number)<br/> ip_protocol = optional(string, "tcp")<br/> prefix_list_id = optional(string)<br/> referenced_security_group_id = optional(string)<br/> region = optional(string)<br/> tags = optional(map(string), {})<br/> to_port = optional(number)<br/> }))</pre> | `{}` | no |
287296
| <a name="input_security_group_ingress_rules"></a> [security\_group\_ingress\_rules](#input\_security\_group\_ingress\_rules) | Map of security group ingress rules to add to the security group created | <pre>map(object({<br/> name = optional(string)<br/><br/> cidr_ipv4 = optional(string)<br/> cidr_ipv6 = optional(string)<br/> description = optional(string)<br/> from_port = optional(number)<br/> ip_protocol = optional(string, "tcp")<br/> prefix_list_id = optional(string)<br/> referenced_security_group_id = optional(string)<br/> region = optional(string)<br/> tags = optional(map(string), {})<br/> to_port = optional(number)<br/> }))</pre> | `{}` | no |
@@ -292,17 +301,13 @@ No modules.
292301
| <a name="input_snapshot_cluster_identifier"></a> [snapshot\_cluster\_identifier](#input\_snapshot\_cluster\_identifier) | The name of the cluster the source snapshot was created from | `string` | `null` | no |
293302
| <a name="input_snapshot_copy"></a> [snapshot\_copy](#input\_snapshot\_copy) | Configuration of automatic copy of snapshots from one region to another | <pre>object({<br/> destination_region = string<br/> manual_snapshot_retention_period = optional(number)<br/> retention_period = optional(number)<br/> grant_name = optional(string)<br/> })</pre> | `null` | no |
294303
| <a name="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier) | The name of the snapshot from which to create the new cluster | `string` | `null` | no |
295-
| <a name="input_snapshot_schedule_definitions"></a> [snapshot\_schedule\_definitions](#input\_snapshot\_schedule\_definitions) | The definition of the snapshot schedule. The definition is made up of schedule expressions, for example `cron(30 12 *)` or `rate(12 hours)` | `list(string)` | `[]` | no |
296-
| <a name="input_snapshot_schedule_description"></a> [snapshot\_schedule\_description](#input\_snapshot\_schedule\_description) | The description of the snapshot schedule | `string` | `null` | no |
297-
| <a name="input_snapshot_schedule_force_destroy"></a> [snapshot\_schedule\_force\_destroy](#input\_snapshot\_schedule\_force\_destroy) | Whether to destroy all associated clusters with this snapshot schedule on deletion. Must be enabled and applied before attempting deletion | `bool` | `null` | no |
298-
| <a name="input_snapshot_schedule_identifier"></a> [snapshot\_schedule\_identifier](#input\_snapshot\_schedule\_identifier) | The snapshot schedule identifier | `string` | `null` | no |
304+
| <a name="input_snapshot_schedule"></a> [snapshot\_schedule](#input\_snapshot\_schedule) | Configuration for creating a snapshot schedule and associating it with the cluster | <pre>object({<br/> definitions = list(string)<br/> description = optional(string)<br/> force_destroy = optional(bool)<br/> use_prefix = optional(bool, false)<br/> identifier = optional(string)<br/> tags = optional(map(string), {})<br/> })</pre> | `null` | no |
299305
| <a name="input_subnet_group_description"></a> [subnet\_group\_description](#input\_subnet\_group\_description) | The description of the Redshift Subnet group. Defaults to `Managed by Terraform` | `string` | `null` | no |
300306
| <a name="input_subnet_group_name"></a> [subnet\_group\_name](#input\_subnet\_group\_name) | The name of the Redshift subnet group, existing or to be created | `string` | `null` | no |
301307
| <a name="input_subnet_group_tags"></a> [subnet\_group\_tags](#input\_subnet\_group\_tags) | Additional tags to add to the subnet group | `map(string)` | `{}` | no |
302308
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | An array of VPC subnet IDs to use in the subnet group | `list(string)` | `[]` | no |
303309
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
304310
| <a name="input_usage_limits"></a> [usage\_limits](#input\_usage\_limits) | Map of usage limit definitions to create | <pre>map(object({<br/> amount = number<br/> breach_action = optional(string)<br/> feature_type = string<br/> limit_type = optional(string) # Will fall back to key if not set<br/> period = optional(string)<br/> tags = optional(map(string), {})<br/> }))</pre> | `{}` | no |
305-
| <a name="input_use_snapshot_identifier_prefix"></a> [use\_snapshot\_identifier\_prefix](#input\_use\_snapshot\_identifier\_prefix) | Determines whether the identifier (`snapshot_schedule_identifier`) is used as a prefix | `bool` | `true` | no |
306311
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | ID of the VPC where to create security group | `string` | `""` | no |
307312
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of Virtual Private Cloud (VPC) security groups to be associated with the cluster | `list(string)` | `[]` | no |
308313

docs/UPGRADE-7.0.md

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,17 @@ Please consult the `examples` directory for reference example configurations. If
3333
- `aqua_configuration_status` argument was deprecated
3434
- The variables for endpoint access have been nested under a single, top-level `endpoint_access` variable:
3535
- `create_endpoint_access` removed - set `endpoint_access` to `null` or omit to disable
36-
- `endpoint_name`
37-
- `endpoint_resource_owner`
38-
- `endpoint_subnet_group_name`
39-
- `endpoint_vpc_security_group_ids`
36+
- `endpoint_name` -> `endpoint_access.name`
37+
- `endpoint_resource_owner` -> `endpoint_access.resource_owner`
38+
- `endpoint_subnet_group_name` -> `endpoint_access.subnet_group_name`
39+
- `endpoint_vpc_security_group_ids` -> `endpoint_access.vpc_security_group_ids`
40+
- The variables for snapshot schedule have been nested under a single, top-level `snapshot_schedule` variable:
41+
- `create_snapshot_schedule` removed - set `snapshot_schedule` to `null` or omit to disable
42+
- `snapshot_schedule_identifier` -> `snapshot_schedule.identifier`
43+
- `use_snapshot_identifier_prefix` -> `snapshot_schedule.use_prefix`
44+
- `snapshot_schedule_description` -> `snapshot_schedule.description`
45+
- `snapshot_schedule_definitions` -> `snapshot_schedule.definitions`
46+
- `snapshot_schedule_force_destroy` -> `snapshot_schedule.force_destroy`
4047

4148
2. Renamed variables:
4249

@@ -75,6 +82,46 @@ module "redshift" {
7582
version = "~> 6.0"
7683
7784
# Only the affected attributes are shown
85+
86+
# Snapshot schedule
87+
create_snapshot_schedule = true
88+
snapshot_schedule_identifier = "example"
89+
use_snapshot_identifier_prefix = true
90+
snapshot_schedule_description = "Example snapshot schedule"
91+
snapshot_schedule_definitions = ["rate(12 hours)"]
92+
snapshot_schedule_force_destroy = true
93+
94+
# Scheduled actions
95+
create_scheduled_action_iam_role = true
96+
scheduled_actions = {
97+
pause = {
98+
name = "example-pause"
99+
description = "Pause cluster every night"
100+
schedule = "cron(0 22 * * ? *)"
101+
pause_cluster = true
102+
}
103+
resize = {
104+
name = "example-resize"
105+
description = "Resize cluster (demo only)"
106+
schedule = "cron(00 13 * * ? *)"
107+
resize_cluster = {
108+
node_type = "ds2.xlarge"
109+
number_of_nodes = 5
110+
}
111+
}
112+
resume = {
113+
name = "example-resume"
114+
description = "Resume cluster every morning"
115+
schedule = "cron(0 12 * * ? *)"
116+
resume_cluster = true
117+
}
118+
}
119+
120+
# Endpoint access - only available when using the ra3.x type
121+
create_endpoint_access = true
122+
endpoint_name = "example-example"
123+
endpoint_subnet_group_name = aws_redshift_subnet_group.endpoint.id
124+
endpoint_vpc_security_group_ids = [module.security_group.security_group_id]
78125
}
79126
```
80127

@@ -86,6 +133,56 @@ module "redshift" {
86133
version = "~> 7.0"
87134
88135
# Only the affected attributes are shown
136+
137+
# Snapshot schedule
138+
snapshot_schedule = {
139+
identifier = "example"
140+
use_prefix = true
141+
description = "Example snapshot schedule"
142+
definitions = ["rate(12 hours)"]
143+
force_destroy = true
144+
}
145+
146+
# Scheduled actions
147+
create_scheduled_action_iam_role = true
148+
scheduled_actions = {
149+
pause = {
150+
name = "example-pause"
151+
description = "Pause cluster every night"
152+
schedule = "cron(0 22 * * ? *)"
153+
target_action = {
154+
pause_cluster = true
155+
}
156+
}
157+
resize = {
158+
name = "example-resize"
159+
description = "Resize cluster (demo only)"
160+
schedule = "cron(00 13 * * ? *)"
161+
target_action = {
162+
resize_cluster = {
163+
node_type = "ds2.xlarge"
164+
number_of_nodes = 5
165+
}
166+
}
167+
}
168+
resume = {
169+
name = "example-resume"
170+
description = "Resume cluster every morning"
171+
schedule = "cron(0 12 * * ? *)"
172+
target_action = {
173+
resume_cluster = true
174+
}
175+
}
176+
}
177+
178+
# Endpoint access - only available when using the ra3.x type
179+
endpoint_access = {
180+
example = {
181+
name = "example-example"
182+
subnet_group_name = aws_redshift_subnet_group.endpoint.id
183+
vpc_security_group_ids = [module.security_group.security_group_id]
184+
}
185+
}
89186
}
90187
```
91188

examples/complete/main.tf

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,17 @@ module "redshift" {
4040

4141
database_name = "mydb"
4242
master_username = "mydbuser"
43-
# Either provide a good master password
44-
# create_random_password = false
45-
# master_password = "MySecretPassw0rd1!" # Do better!
46-
# Or make Redshift manage it in secrets manager
47-
manage_master_password = true
4843

44+
manage_master_password = true
4945
manage_master_password_rotation = true
5046
master_password_rotation_schedule_expression = "rate(90 days)"
5147

5248
encrypted = true
5349
kms_key_arn = aws_kms_key.redshift.arn
5450

55-
enhanced_vpc_routing = true
56-
subnet_ids = module.vpc.redshift_subnets
57-
5851
# Only available when using the ra3.x type
5952
availability_zone_relocation_enabled = true
53+
enhanced_vpc_routing = true
6054

6155
snapshot_copy = {
6256
destination_region = "us-east-1"
@@ -108,17 +102,19 @@ module "redshift" {
108102
# Subnet group
109103
subnet_group_name = "${local.name}-custom"
110104
subnet_group_description = "Custom subnet group for ${local.name} cluster"
105+
subnet_ids = module.vpc.redshift_subnets
111106
subnet_group_tags = {
112107
Additional = "CustomSubnetGroup"
113108
}
114109

115110
# Snapshot schedule
116-
create_snapshot_schedule = true
117-
snapshot_schedule_identifier = local.name
118-
use_snapshot_identifier_prefix = true
119-
snapshot_schedule_description = "Example snapshot schedule"
120-
snapshot_schedule_definitions = ["rate(12 hours)"]
121-
snapshot_schedule_force_destroy = true
111+
snapshot_schedule = {
112+
identifier = local.name
113+
use_prefix = true
114+
description = "Example snapshot schedule"
115+
definitions = ["rate(12 hours)"]
116+
force_destroy = true
117+
}
122118

123119
# Scheduled actions
124120
create_scheduled_action_iam_role = true
@@ -128,7 +124,7 @@ module "redshift" {
128124
description = "Pause cluster every night"
129125
schedule = "cron(0 22 * * ? *)"
130126
target_action = {
131-
pause_cluster = {}
127+
pause_cluster = true
132128
}
133129
}
134130
resize = {
@@ -147,7 +143,7 @@ module "redshift" {
147143
description = "Resume cluster every morning"
148144
schedule = "cron(0 12 * * ? *)"
149145
target_action = {
150-
resume_cluster = {}
146+
resume_cluster = true
151147
}
152148
}
153149
}

0 commit comments

Comments
 (0)