Skip to content

Commit cb41a4c

Browse files
yariksheptykinactions-botnitrocodecloudpossebot
authored
Add option to define character set (#71)
* Add option to define character set * Document selection of character set * Updated README.md * Auto Format Co-authored-by: actions-bot <[email protected]> Co-authored-by: nitrocode <[email protected]> Co-authored-by: cloudpossebot <[email protected]>
1 parent 3b6b1e8 commit cb41a4c

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,42 @@ module "rds_instance" {
159159
]
160160
}
161161
```
162+
### Character Sets
163+
164+
If you wish to create the database in a specific character set you can use one of the following options depending
165+
on your database engine of choice.
166+
167+
For Oracle and Microsoft SQL you can specify charset name as an input variable
168+
to this module. For example, for Microsoft SQL, you could use:
169+
```hcl
170+
module "rds_instance" {
171+
...
172+
charset_name = "Korean_Wansung_CI_AS"
173+
...
174+
}
175+
```
176+
177+
For `mysql` and `mariadb` engines character set of the database can be defined via `db_parameter`. In this example
178+
the database is created with `utf8mb4` (character set) and utf8mb4_unicode_ci (collation):
179+
180+
```hcl
181+
module "rds_instance" {
182+
...
183+
db_parameter = [
184+
{
185+
name = "character_set_server"
186+
value = "utf8mb4"
187+
apply_method = "immediate"
188+
},
189+
{
190+
name = "collation_server"
191+
value = "utf8mb4_unicode_ci"
192+
apply_method = "immediate"
193+
}
194+
]
195+
...
196+
}
197+
```
162198

163199

164200

@@ -230,6 +266,7 @@ Available targets:
230266
| <a name="input_backup_retention_period"></a> [backup\_retention\_period](#input\_backup\_retention\_period) | Backup retention period in days. Must be > 0 to enable backups | `number` | `0` | no |
231267
| <a name="input_backup_window"></a> [backup\_window](#input\_backup\_window) | When AWS can perform DB snapshots, can't overlap with maintenance window | `string` | `"22:00-03:00"` | no |
232268
| <a name="input_ca_cert_identifier"></a> [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | The identifier of the CA certificate for the DB instance | `string` | `null` | no |
269+
| <a name="input_charset_name"></a> [charset\_name](#input\_charset\_name) | The character set name to use for DB encoding. [Oracle & Microsoft SQL only](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#character_set_name). For other engines use `db_parameter` | `string` | `null` | no |
233270
| <a name="input_context"></a> [context](#input\_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. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
234271
| <a name="input_copy_tags_to_snapshot"></a> [copy\_tags\_to\_snapshot](#input\_copy\_tags\_to\_snapshot) | Copy tags from DB to a snapshot | `bool` | `true` | no |
235272
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | The name of the database to create when the DB instance is created | `string` | n/a | yes |

README.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,42 @@ usage: |-
9494
]
9595
}
9696
```
97+
### Character Sets
98+
99+
If you wish to create the database in a specific character set you can use one of the following options depending
100+
on your database engine of choice.
101+
102+
For Oracle and Microsoft SQL you can specify charset name as an input variable
103+
to this module. For example, for Microsoft SQL, you could use:
104+
```hcl
105+
module "rds_instance" {
106+
...
107+
charset_name = "Korean_Wansung_CI_AS"
108+
...
109+
}
110+
```
111+
112+
For `mysql` and `mariadb` engines character set of the database can be defined via `db_parameter`. In this example
113+
the database is created with `utf8mb4` (character set) and utf8mb4_unicode_ci (collation):
114+
115+
```hcl
116+
module "rds_instance" {
117+
...
118+
db_parameter = [
119+
{
120+
name = "character_set_server"
121+
value = "utf8mb4"
122+
apply_method = "immediate"
123+
},
124+
{
125+
name = "collation_server"
126+
value = "utf8mb4_unicode_ci"
127+
apply_method = "immediate"
128+
}
129+
]
130+
...
131+
}
132+
```
97133
include:
98134
- docs/targets.md
99135
- docs/terraform.md

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
| <a name="input_backup_retention_period"></a> [backup\_retention\_period](#input\_backup\_retention\_period) | Backup retention period in days. Must be > 0 to enable backups | `number` | `0` | no |
5252
| <a name="input_backup_window"></a> [backup\_window](#input\_backup\_window) | When AWS can perform DB snapshots, can't overlap with maintenance window | `string` | `"22:00-03:00"` | no |
5353
| <a name="input_ca_cert_identifier"></a> [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | The identifier of the CA certificate for the DB instance | `string` | `null` | no |
54+
| <a name="input_charset_name"></a> [charset\_name](#input\_charset\_name) | The character set name to use for DB encoding. [Oracle & Microsoft SQL only](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#character_set_name). For other engines use `db_parameter` | `string` | `null` | no |
5455
| <a name="input_context"></a> [context](#input\_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. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
5556
| <a name="input_copy_tags_to_snapshot"></a> [copy\_tags\_to\_snapshot](#input\_copy\_tags\_to\_snapshot) | Copy tags from DB to a snapshot | `bool` | `true` | no |
5657
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | The name of the database to create when the DB instance is created | `string` | n/a | yes |

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ resource "aws_db_instance" "default" {
2929
port = var.database_port
3030
engine = var.engine
3131
engine_version = var.engine_version
32+
character_set_name = var.charset_name
3233
instance_class = var.instance_class
3334
allocated_storage = var.allocated_storage
3435
max_allocated_storage = var.max_allocated_storage

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ variable "major_engine_version" {
114114
# https://docs.aws.amazon.com/cli/latest/reference/rds/create-option-group.html
115115
}
116116

117+
variable "charset_name" {
118+
type = string
119+
description = "The character set name to use for DB encoding. [Oracle & Microsoft SQL only](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#character_set_name). For other engines use `db_parameter`"
120+
default = null
121+
}
122+
117123
variable "license_model" {
118124
type = string
119125
description = "License model for this DB. Optional, but required for some DB Engines. Valid values: license-included | bring-your-own-license | general-public-license"

0 commit comments

Comments
 (0)