On Oracle RDS DB instances you can't change the encoding

of the database after creation. So we need to be able to
set the CharacterSetName on creation.
This is an option and will automagically default to
AL32UTF8.

The AWS SDK will give you an error message if you try to
apply this setting to other engines. The patch will only
report the character_set_name attribute, if CharacterSetName
is set on the instance.

Signed-off-by: Lars Bahner <lars.bahner@gmail.com>
This commit is contained in:
Lars Bahner 2016-01-27 18:39:00 +01:00
parent 59a58d8f59
commit 8f2d39be45
2 changed files with 21 additions and 0 deletions

View File

@ -65,6 +65,13 @@ func resourceAwsDbInstance() *schema.Resource {
Computed: true, Computed: true,
}, },
"character_set_name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"storage_encrypted": &schema.Schema{ "storage_encrypted": &schema.Schema{
Type: schema.TypeBool, Type: schema.TypeBool,
Optional: true, Optional: true,
@ -440,6 +447,10 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.MultiAZ = aws.Bool(attr.(bool)) opts.MultiAZ = aws.Bool(attr.(bool))
} }
if attr, ok := d.GetOk("character_set_name"); ok {
opts.CharacterSetName = aws.String(attr.(string))
}
if attr, ok := d.GetOk("maintenance_window"); ok { if attr, ok := d.GetOk("maintenance_window"); ok {
opts.PreferredMaintenanceWindow = aws.String(attr.(string)) opts.PreferredMaintenanceWindow = aws.String(attr.(string))
} }
@ -558,6 +569,10 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("db_subnet_group_name", v.DBSubnetGroup.DBSubnetGroupName) d.Set("db_subnet_group_name", v.DBSubnetGroup.DBSubnetGroupName)
} }
if v.CharacterSetName != nil {
d.Set("character_set_name", v.CharacterSetName)
}
if len(v.DBParameterGroups) > 0 { if len(v.DBParameterGroups) > 0 {
d.Set("parameter_group_name", v.DBParameterGroups[0].DBParameterGroupName) d.Set("parameter_group_name", v.DBParameterGroups[0].DBParameterGroupName)
} }

View File

@ -99,6 +99,8 @@ database, and to use this value as the source database. This correlates to the
* `license_model` - (Optional, but required for some DB engines, i.e. Oracle SE1) License model information for this DB instance. * `license_model` - (Optional, but required for some DB engines, i.e. Oracle SE1) License model information for this DB instance.
* `auto_minor_version_upgrade` - (Optional) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Defaults to true. * `auto_minor_version_upgrade` - (Optional) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Defaults to true.
* `allow_major_version_upgrade` - (Optional) Indicates that major version upgrades are allowed. Changing this parameter does not result in an outage and the change is asynchronously applied as soon as possible. * `allow_major_version_upgrade` - (Optional) Indicates that major version upgrades are allowed. Changing this parameter does not result in an outage and the change is asynchronously applied as soon as possible.
* `charater_set_name` - (Optional) The character set name to use for DB encoding in Oracle instances. This can't be changed.
[Oracle Character Sets Supported in Amazon RDS](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.OracleCharacterSets.html)
~> **NOTE:** Removing the `replicate_source_db` attribute from an existing RDS ~> **NOTE:** Removing the `replicate_source_db` attribute from an existing RDS
Replicate database managed by Terraform will promote the database to a fully Replicate database managed by Terraform will promote the database to a fully
@ -127,5 +129,9 @@ The following attributes are exported:
* `username` - The master username for the database * `username` - The master username for the database
* `storage_encrypted` - Specifies whether the DB instance is encrypted * `storage_encrypted` - Specifies whether the DB instance is encrypted
On Oracle instances the following is exported additionally:
* `character_set_name` - The character set used on Oracle instances.
[1]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Replication.html [1]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Replication.html
[2]: https://docs.aws.amazon.com/fr_fr/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html [2]: https://docs.aws.amazon.com/fr_fr/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html