Skip to content

Commit 5c17710

Browse files
authored
Update to context.tf. Add primary and secondary cluster resources (cloudposse#79)
* Update to `context.tf` * Update to `context.tf` * Update to `context.tf` * Update to `context.tf`
1 parent 8c5fac8 commit 5c17710

File tree

16 files changed

+534
-163
lines changed

16 files changed

+534
-163
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212

1313
# Cloud Posse must review any changes to GitHub actions
1414
.github/* @cloudposse/engineering
15+
16+
# Cloud Posse must review any changes to standard context definition
17+
**/context.tf @cloudposse/engineering

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017-2019 Cloud Posse, LLC
189+
Copyright 2017-2020 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,24 +264,26 @@ Available targets:
264264
265265
```
266266
<!-- markdownlint-restore -->
267+
<!-- markdownlint-disable -->
267268
## Requirements
268269

269270
| Name | Version |
270271
|------|---------|
271-
| terraform | >= 0.12.0, < 0.14.0 |
272-
| aws | ~> 2.0 |
273-
| null | ~> 2.0 |
272+
| terraform | >= 0.12.0 |
273+
| aws | >= 2.0 |
274+
| null | >= 2.0 |
274275

275276
## Providers
276277

277278
| Name | Version |
278279
|------|---------|
279-
| aws | ~> 2.0 |
280+
| aws | >= 2.0 |
280281

281282
## Inputs
282283

283284
| Name | Description | Type | Default | Required |
284285
|------|-------------|------|---------|:--------:|
286+
| additional\_tag\_map | Additional tags for appending to tags\_as\_list\_of\_maps. Not added to `tags`. | `map(string)` | `{}` | no |
285287
| admin\_password | (Required unless a snapshot\_identifier is provided) Password for the master DB user | `string` | `""` | no |
286288
| admin\_user | (Required unless a snapshot\_identifier is provided) Username for the master DB user | `string` | `"admin"` | no |
287289
| allowed\_cidr\_blocks | List of CIDR blocks allowed to access the cluster | `list(string)` | `[]` | no |
@@ -303,42 +305,46 @@ Available targets:
303305
| cluster\_identifier | The RDS Cluster Identifier. Will use generated label ID if not supplied | `string` | `""` | no |
304306
| cluster\_parameters | List of DB cluster parameters to apply | <pre>list(object({<br> apply_method = string<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
305307
| cluster\_size | Number of DB instances to create in the cluster | `number` | `2` | no |
308+
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
306309
| copy\_tags\_to\_snapshot | Copy tags to backup snapshots | `bool` | `false` | no |
307310
| db\_name | Database name (default is not to create a database) | `string` | `""` | no |
308311
| db\_port | Database port | `number` | `3306` | no |
309312
| deletion\_protection | If the DB instance should have deletion protection enabled | `bool` | `false` | no |
310-
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes` | `string` | `"-"` | no |
313+
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
311314
| enable\_http\_endpoint | Enable HTTP endpoint (data API). Only valid when engine\_mode is set to serverless | `bool` | `false` | no |
312-
| enabled | Set to false to prevent the module from creating any resources | `bool` | `true` | no |
315+
| enabled | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
313316
| enabled\_cloudwatch\_logs\_exports | List of log types to export to cloudwatch. The following log types are supported: audit, error, general, slowquery | `list(string)` | `[]` | no |
314317
| engine | The name of the database engine to be used for this DB cluster. Valid values: `aurora`, `aurora-mysql`, `aurora-postgresql` | `string` | `"aurora"` | no |
315318
| engine\_mode | The database engine mode. Valid values: `parallelquery`, `provisioned`, `serverless` | `string` | `"provisioned"` | no |
316319
| engine\_version | The version of the database engine to use. See `aws rds describe-db-engine-versions` | `string` | `""` | no |
317-
| environment | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `""` | no |
320+
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
318321
| global\_cluster\_identifier | ID of the Aurora global cluster | `string` | `""` | no |
319322
| iam\_database\_authentication\_enabled | Specifies whether or mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled | `bool` | `false` | no |
320323
| iam\_roles | Iam roles for the Aurora cluster | `list(string)` | `[]` | no |
324+
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
321325
| instance\_availability\_zone | Optional parameter to place cluster instances in a specific availability zone. If left empty, will place randomly | `string` | `""` | no |
322326
| instance\_parameters | List of DB instance parameters to apply | <pre>list(object({<br> apply_method = string<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
323327
| instance\_type | Instance type to use | `string` | `"db.t2.small"` | no |
324328
| kms\_key\_arn | The ARN for the KMS encryption key. When specifying `kms_key_arn`, `storage_encrypted` needs to be set to `true` | `string` | `""` | no |
329+
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
325330
| maintenance\_window | Weekly time range during which system maintenance can occur, in UTC | `string` | `"wed:03:00-wed:04:00"` | no |
326-
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `""` | no |
327-
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `""` | no |
331+
| name | Solution name, e.g. 'app' or 'jenkins' | `string` | `null` | no |
332+
| namespace | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
328333
| performance\_insights\_enabled | Whether to enable Performance Insights | `bool` | `false` | no |
329334
| performance\_insights\_kms\_key\_id | The ARN for the KMS key to encrypt Performance Insights data. When specifying `performance_insights_kms_key_id`, `performance_insights_enabled` needs to be set to true | `string` | `""` | no |
330335
| publicly\_accessible | Set to true if you want your cluster to be publicly accessible (such as via QuickSight) | `bool` | `false` | no |
331336
| rds\_monitoring\_interval | Interval in seconds that metrics are collected, 0 to disable (values can only be 0, 1, 5, 10, 15, 30, 60) | `number` | `0` | no |
332337
| rds\_monitoring\_role\_arn | The ARN for the IAM role that can send monitoring metrics to CloudWatch Logs | `string` | `""` | no |
333338
| reader\_dns\_name | Name of the reader endpoint CNAME record to create in the parent DNS zone specified by `zone_id`. If left empty, the name will be auto-asigned using the format `replicas.var.name` | `string` | `""` | no |
339+
| regex\_replace\_chars | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
334340
| replication\_source\_identifier | ARN of a source DB cluster or DB instance if this DB cluster is to be created as a Read Replica | `string` | `""` | no |
335341
| retention\_period | Number of days to retain backups for | `number` | `5` | no |
336342
| scaling\_configuration | List of nested attributes with scaling properties. Only valid when `engine_mode` is set to `serverless` | <pre>list(object({<br> auto_pause = bool<br> max_capacity = number<br> min_capacity = number<br> seconds_until_auto_pause = number<br> timeout_action = string<br> }))</pre> | `[]` | no |
337343
| security\_groups | List of security groups to be allowed to connect to the DB instance | `list(string)` | `[]` | no |
338344
| skip\_final\_snapshot | Determines whether a final DB snapshot is created before the DB cluster is deleted | `bool` | `true` | no |
339345
| snapshot\_identifier | Specifies whether or not to create this cluster from a snapshot | `string` | `""` | no |
340346
| source\_region | Source Region of primary cluster, needed when using encrypted storage and region replicas | `string` | `""` | no |
341-
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `""` | no |
347+
| stage | Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
342348
| storage\_encrypted | Specifies whether the DB cluster is encrypted. The default is `false` for `provisioned` `engine_mode` and `true` for `serverless` `engine_mode` | `bool` | `false` | no |
343349
| subnets | List of VPC subnet IDs | `list(string)` | n/a | yes |
344350
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | `map(string)` | `{}` | no |
@@ -351,7 +357,7 @@ Available targets:
351357

352358
| Name | Description |
353359
|------|-------------|
354-
| arn | Amazon Resource Name (ARN) of cluster |
360+
| arn | Amazon Resource Name (ARN) of the cluster |
355361
| cluster\_identifier | Cluster Identifier |
356362
| cluster\_resource\_id | The region-unique, immutable identifie of the cluster |
357363
| cluster\_security\_groups | Default RDS cluster security groups |
@@ -363,6 +369,7 @@ Available targets:
363369
| reader\_endpoint | A read-only endpoint for the Aurora cluster, automatically load-balanced across replicas |
364370
| replicas\_host | Replicas hostname |
365371

372+
<!-- markdownlint-restore -->
366373

367374

368375

context.tf

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#
2+
# ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
3+
# All other instances of this file should be a copy of that one
4+
#
5+
#
6+
# Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
7+
# and then place it in your Terraform module to automatically get
8+
# Cloud Posse's standard configuration inputs suitable for passing
9+
# to Cloud Posse modules.
10+
#
11+
# Modules should access the whole context as `module.this.context`
12+
# to get the input variables with nulls for defaults,
13+
# for example `context = module.this.context`,
14+
# and access individual variables as `module.this.<var>`,
15+
# with final values filled in.
16+
#
17+
# For example, when using defaults, `module.this.context.delimiter`
18+
# will be null, and `module.this.delimiter` will be `-` (hyphen).
19+
#
20+
21+
module "this" {
22+
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.19.2"
23+
24+
enabled = var.enabled
25+
namespace = var.namespace
26+
environment = var.environment
27+
stage = var.stage
28+
name = var.name
29+
delimiter = var.delimiter
30+
attributes = var.attributes
31+
tags = var.tags
32+
additional_tag_map = var.additional_tag_map
33+
label_order = var.label_order
34+
regex_replace_chars = var.regex_replace_chars
35+
id_length_limit = var.id_length_limit
36+
37+
context = var.context
38+
}
39+
40+
# Copy contents of cloudposse/terraform-null-label/variables.tf here
41+
42+
variable "context" {
43+
type = object({
44+
enabled = bool
45+
namespace = string
46+
environment = string
47+
stage = string
48+
name = string
49+
delimiter = string
50+
attributes = list(string)
51+
tags = map(string)
52+
additional_tag_map = map(string)
53+
regex_replace_chars = string
54+
label_order = list(string)
55+
id_length_limit = number
56+
})
57+
default = {
58+
enabled = true
59+
namespace = null
60+
environment = null
61+
stage = null
62+
name = null
63+
delimiter = null
64+
attributes = []
65+
tags = {}
66+
additional_tag_map = {}
67+
regex_replace_chars = null
68+
label_order = []
69+
id_length_limit = null
70+
}
71+
description = <<-EOT
72+
Single object for setting entire context at once.
73+
See description of individual variables for details.
74+
Leave string and numeric variables as `null` to use default value.
75+
Individual variable settings (non-null) override settings in context object,
76+
except for attributes, tags, and additional_tag_map, which are merged.
77+
EOT
78+
}
79+
80+
variable "enabled" {
81+
type = bool
82+
default = null
83+
description = "Set to false to prevent the module from creating any resources"
84+
}
85+
86+
variable "namespace" {
87+
type = string
88+
default = null
89+
description = "Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp'"
90+
}
91+
92+
variable "environment" {
93+
type = string
94+
default = null
95+
description = "Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT'"
96+
}
97+
98+
variable "stage" {
99+
type = string
100+
default = null
101+
description = "Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release'"
102+
}
103+
104+
variable "name" {
105+
type = string
106+
default = null
107+
description = "Solution name, e.g. 'app' or 'jenkins'"
108+
}
109+
110+
variable "delimiter" {
111+
type = string
112+
default = null
113+
description = <<-EOT
114+
Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.
115+
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
116+
EOT
117+
}
118+
119+
variable "attributes" {
120+
type = list(string)
121+
default = []
122+
description = "Additional attributes (e.g. `1`)"
123+
}
124+
125+
variable "tags" {
126+
type = map(string)
127+
default = {}
128+
description = "Additional tags (e.g. `map('BusinessUnit','XYZ')`"
129+
}
130+
131+
variable "additional_tag_map" {
132+
type = map(string)
133+
default = {}
134+
description = "Additional tags for appending to tags_as_list_of_maps. Not added to `tags`."
135+
}
136+
137+
variable "label_order" {
138+
type = list(string)
139+
default = null
140+
description = <<-EOT
141+
The naming order of the id output and Name tag.
142+
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
143+
You can omit any of the 5 elements, but at least one must be present.
144+
EOT
145+
}
146+
147+
variable "regex_replace_chars" {
148+
type = string
149+
default = null
150+
description = <<-EOT
151+
Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.
152+
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
153+
EOT
154+
}
155+
156+
variable "id_length_limit" {
157+
type = number
158+
default = null
159+
description = <<-EOT
160+
Limit `id` to this many characters.
161+
Set to `0` for unlimited length.
162+
Set to `null` for default, which is `0`.
163+
Does not affect `id_full`.
164+
EOT
165+
}
166+
167+
#### End of copy of cloudposse/terraform-null-label/variables.tf

0 commit comments

Comments
 (0)