Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle only national character set #20437

Merged
merged 5 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ func resourceAwsDbInstance() *schema.Resource {
Computed: true,
ForceNew: true,
},
"national_character_set": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
"option_group_name": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1151,6 +1157,10 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.CharacterSetName = aws.String(attr.(string))
}

if attr, ok := d.GetOk("national_character_set"); ok {
opts.NcharCharacterSetName = aws.String(attr.(string))
}

if attr, ok := d.GetOk("timezone"); ok {
opts.Timezone = aws.String(attr.(string))
}
Expand Down Expand Up @@ -1381,6 +1391,10 @@ func resourceAwsDbInstanceRead(d *schema.ResourceData, meta interface{}) error {
d.Set("character_set_name", v.CharacterSetName)
}

if v.NcharCharacterSetName != nil {
d.Set("national_character_set", v.NcharCharacterSetName)
}

d.Set("timezone", v.Timezone)

if len(v.DBParameterGroups) > 0 {
Expand Down
120 changes: 118 additions & 2 deletions aws/resource_aws_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3290,6 +3290,75 @@ func TestAccAWSDBInstance_RestoreToPointInTime_SourceResourceID(t *testing.T) {
})
}

func TestAccAWSDBInstance_NationalCharacterSet_Oracle(t *testing.T) {
var dbInstance rds.DBInstance

rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_db_instance.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, rds.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDBInstanceConfig_NationalCharacterSet_Oracle(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists(resourceName, &dbInstance),
resource.TestCheckResourceAttr(resourceName, "national_character_set", "UTF8"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"apply_immediately",
"final_snapshot_identifier",
"password",
"skip_final_snapshot",
"delete_automated_backups",
},
},
},
})
}

func TestAccAWSDBInstance_NoNationalCharacterSet_Oracle(t *testing.T) {
var dbInstance rds.DBInstance

rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_db_instance.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ErrorCheck: testAccErrorCheck(t, rds.EndpointsID),
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDBInstanceConfig_NoNationalCharacterSet_Oracle(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists(resourceName, &dbInstance),
resource.TestCheckResourceAttr(resourceName, "national_character_set", "AL16UTF16"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"apply_immediately",
"final_snapshot_identifier",
"password",
"skip_final_snapshot",
"delete_automated_backups",
},
},
},
})
}
func testAccAWSDBInstanceConfig_orderableClass(engine, version, license string) string {
return fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
Expand Down Expand Up @@ -5120,8 +5189,7 @@ resource "aws_db_instance" "test" {
func testAccAWSDBInstanceConfig_EnabledCloudwatchLogsExports_Oracle(rName string) string {
return fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
engine = "oracle-se"
engine_version = "11.2.0.4.v25"
engine = "oracle-se2"
license_model = "bring-your-own-license"
storage_type = "standard"

Expand All @@ -5134,6 +5202,54 @@ resource "aws_db_instance" "test" {
engine = data.aws_rds_orderable_db_instance.test.engine
identifier = %q
instance_class = data.aws_rds_orderable_db_instance.test.instance_class
license_model = "bring-your-own-license"
password = "avoid-plaintext-passwords"
username = "tfacctest"
skip_final_snapshot = true
}
`, rName)
}

func testAccAWSDBInstanceConfig_NationalCharacterSet_Oracle(rName string) string {
return fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
engine = "oracle-se2"
license_model = "bring-your-own-license"
storage_type = "standard"

preferred_instance_classes = ["db.m5.large", "db.m4.large", "db.r4.large"]
}

resource "aws_db_instance" "test" {
allocated_storage = 10
engine = data.aws_rds_orderable_db_instance.test.engine
identifier = %q
instance_class = data.aws_rds_orderable_db_instance.test.instance_class
license_model = "bring-your-own-license"
national_character_set = "UTF8"
password = "avoid-plaintext-passwords"
username = "tfacctest"
skip_final_snapshot = true
}
`, rName)
}

func testAccAWSDBInstanceConfig_NoNationalCharacterSet_Oracle(rName string) string {
return fmt.Sprintf(`
data "aws_rds_orderable_db_instance" "test" {
engine = "oracle-se2"
license_model = "bring-your-own-license"
storage_type = "standard"

preferred_instance_classes = ["db.m5.large", "db.m4.large", "db.r4.large"]
}

resource "aws_db_instance" "test" {
allocated_storage = 10
engine = data.aws_rds_orderable_db_instance.test.engine
identifier = %q
instance_class = data.aws_rds_orderable_db_instance.test.instance_class
license_model = "bring-your-own-license"
password = "avoid-plaintext-passwords"
username = "tfacctest"
skip_final_snapshot = true
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/db_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ Documentation](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monit
what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances.
* `multi_az` - (Optional) Specifies if the RDS instance is multi-AZ
* `name` - (Optional) The name of the database to create when the DB instance is created. If this parameter is not specified, no database is created in the DB instance. Note that this does not apply for Oracle or SQL Server engines. See the [AWS documentation](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/rds/create-db-instance.html) for more details on what applies for those engines. If you are providing an Oracle db name, it needs to be in all upper case.
* `national_character_set` - (Optional, Forces new resource) The national character set is used in the NCHAR, NVARCHAR2, and NCLOB data types for Oracle instances. This can't be changed. See [Oracle Character Sets
Supported in Amazon RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.OracleCharacterSets.html).
* `option_group_name` - (Optional) Name of the DB option group to associate.
* `parameter_group_name` - (Optional) Name of the DB parameter group to
associate.
Expand Down