diff --git a/README.md b/README.md
index bf15ace..9a59e79 100644
--- a/README.md
+++ b/README.md
@@ -159,6 +159,42 @@ module "rds_instance" {
]
}
```
+### Character Sets
+
+If you wish to create the database in a specific character set you can use one of the following options depending
+on your database engine of choice.
+
+For Oracle and Microsoft SQL you can specify charset name as an input variable
+to this module. For example, for Microsoft SQL, you could use:
+```hcl
+module "rds_instance" {
+ ...
+ charset_name = "Korean_Wansung_CI_AS"
+ ...
+}
+```
+
+For `mysql` and `mariadb` engines character set of the database can be defined via `db_parameter`. In this example
+the database is created with `utf8mb4` (character set) and utf8mb4_unicode_ci (collation):
+
+```hcl
+module "rds_instance" {
+ ...
+ db_parameter = [
+ {
+ name = "character_set_server"
+ value = "utf8mb4"
+ apply_method = "immediate"
+ },
+ {
+ name = "collation_server"
+ value = "utf8mb4_unicode_ci"
+ apply_method = "immediate"
+ }
+ ]
+ ...
+}
+```
@@ -230,6 +266,7 @@ Available targets:
| [backup\_retention\_period](#input\_backup\_retention\_period) | Backup retention period in days. Must be > 0 to enable backups | `number` | `0` | no |
| [backup\_window](#input\_backup\_window) | When AWS can perform DB snapshots, can't overlap with maintenance window | `string` | `"22:00-03:00"` | no |
| [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | The identifier of the CA certificate for the DB instance | `string` | `null` | no |
+| [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 |
| [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
} | no |
| [copy\_tags\_to\_snapshot](#input\_copy\_tags\_to\_snapshot) | Copy tags from DB to a snapshot | `bool` | `true` | no |
| [database\_name](#input\_database\_name) | The name of the database to create when the DB instance is created | `string` | n/a | yes |
diff --git a/README.yaml b/README.yaml
index a464d8f..68f48e2 100644
--- a/README.yaml
+++ b/README.yaml
@@ -94,6 +94,42 @@ usage: |-
]
}
```
+ ### Character Sets
+
+ If you wish to create the database in a specific character set you can use one of the following options depending
+ on your database engine of choice.
+
+ For Oracle and Microsoft SQL you can specify charset name as an input variable
+ to this module. For example, for Microsoft SQL, you could use:
+ ```hcl
+ module "rds_instance" {
+ ...
+ charset_name = "Korean_Wansung_CI_AS"
+ ...
+ }
+ ```
+
+ For `mysql` and `mariadb` engines character set of the database can be defined via `db_parameter`. In this example
+ the database is created with `utf8mb4` (character set) and utf8mb4_unicode_ci (collation):
+
+ ```hcl
+ module "rds_instance" {
+ ...
+ db_parameter = [
+ {
+ name = "character_set_server"
+ value = "utf8mb4"
+ apply_method = "immediate"
+ },
+ {
+ name = "collation_server"
+ value = "utf8mb4_unicode_ci"
+ apply_method = "immediate"
+ }
+ ]
+ ...
+ }
+ ```
include:
- docs/targets.md
- docs/terraform.md
diff --git a/docs/terraform.md b/docs/terraform.md
index f99deb0..862a7b3 100644
--- a/docs/terraform.md
+++ b/docs/terraform.md
@@ -51,6 +51,7 @@
| [backup\_retention\_period](#input\_backup\_retention\_period) | Backup retention period in days. Must be > 0 to enable backups | `number` | `0` | no |
| [backup\_window](#input\_backup\_window) | When AWS can perform DB snapshots, can't overlap with maintenance window | `string` | `"22:00-03:00"` | no |
| [ca\_cert\_identifier](#input\_ca\_cert\_identifier) | The identifier of the CA certificate for the DB instance | `string` | `null` | no |
+| [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 |
| [context](#input\_context) | Single object for setting entire context at once.{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {}
} | no |
| [copy\_tags\_to\_snapshot](#input\_copy\_tags\_to\_snapshot) | Copy tags from DB to a snapshot | `bool` | `true` | no |
| [database\_name](#input\_database\_name) | The name of the database to create when the DB instance is created | `string` | n/a | yes |
diff --git a/main.tf b/main.tf
index 9579337..8b8614e 100644
--- a/main.tf
+++ b/main.tf
@@ -29,6 +29,7 @@ resource "aws_db_instance" "default" {
port = var.database_port
engine = var.engine
engine_version = var.engine_version
+ character_set_name = var.charset_name
instance_class = var.instance_class
allocated_storage = var.allocated_storage
max_allocated_storage = var.max_allocated_storage
diff --git a/variables.tf b/variables.tf
index 69a4ddd..1fc7db4 100644
--- a/variables.tf
+++ b/variables.tf
@@ -114,6 +114,12 @@ variable "major_engine_version" {
# https://docs.aws.amazon.com/cli/latest/reference/rds/create-option-group.html
}
+variable "charset_name" {
+ type = string
+ 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`"
+ default = null
+}
+
variable "license_model" {
type = string
description = "License model for this DB. Optional, but required for some DB Engines. Valid values: license-included | bring-your-own-license | general-public-license"