diff --git a/.changelog/35626.txt b/.changelog/35626.txt new file mode 100644 index 00000000000..962faa17df6 --- /dev/null +++ b/.changelog/35626.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_db_instance: Add `diag.log` and `notify.log` as valid values for `enabled_cloudwatch_logs_exports` +``` diff --git a/internal/service/rds/consts.go b/internal/service/rds/consts.go index fbe01a3fd84..8252ac9d8c5 100644 --- a/internal/service/rds/consts.go +++ b/internal/service/rds/consts.go @@ -185,9 +185,11 @@ const ( ExportableLogTypeAgent = "agent" ExportableLogTypeAlert = "alert" ExportableLogTypeAudit = "audit" + ExportableLogTypeDiagLog = "diag.log" ExportableLogTypeError = "error" ExportableLogTypeGeneral = "general" ExportableLogTypeListener = "listener" + ExportableLogTypeNotifyLog = "notify.log" ExportableLogTypeOEMAgent = "oemagent" ExportableLogTypePostgreSQL = "postgresql" ExportableLogTypeSlowQuery = "slowquery" @@ -211,9 +213,11 @@ func InstanceExportableLogType_Values() []string { ExportableLogTypeAgent, ExportableLogTypeAlert, ExportableLogTypeAudit, + ExportableLogTypeDiagLog, ExportableLogTypeError, ExportableLogTypeGeneral, ExportableLogTypeListener, + ExportableLogTypeNotifyLog, ExportableLogTypeOEMAgent, ExportableLogTypePostgreSQL, ExportableLogTypeSlowQuery, diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index b0ac0e9b3dc..96d30c80ace 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -3820,6 +3820,48 @@ func TestAccRDSInstance_cloudWatchLogsExport(t *testing.T) { }) } +func TestAccRDSInstance_EnabledCloudWatchLogsExports_db2(t *testing.T) { + ctx := acctest.Context(t) + if testing.Short() { + t.Skip("skipping long-running test in short mode") + } + + var v rds.DBInstance + rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) + resourceName := "aws_db_instance.test" + // Requires an IBM Db2 License set as environmental variable. + // Licensing pre-requisite: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/db2-licensing.html. + customerID := acctest.SkipIfEnvVarNotSet(t, "RDS_DB2_CUSTOMER_ID") + siteID := acctest.SkipIfEnvVarNotSet(t, "RDS_DB2_SITE_ID") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(ctx, t) }, + ErrorCheck: acctest.ErrorCheck(t, rds.EndpointsID), + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, + CheckDestroy: testAccCheckInstanceDestroy(ctx), + Steps: []resource.TestStep{ + { + Config: testAccInstanceConfig_EnabledCloudWatchLogsExports_db2(rName, customerID, siteID), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckInstanceExists(ctx, resourceName, &v), + resource.TestCheckResourceAttr(resourceName, "enabled_cloudwatch_logs_exports.#", "2"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "apply_immediately", + "final_snapshot_identifier", + "password", + "skip_final_snapshot", + }, + }, + }, + }) +} + func TestAccRDSInstance_EnabledCloudWatchLogsExports_mySQL(t *testing.T) { ctx := acctest.Context(t) if testing.Short() { @@ -7860,6 +7902,42 @@ resource "aws_db_instance" "test" { `, deletionProtection, rName)) } +func testAccInstanceConfig_EnabledCloudWatchLogsExports_db2(rName, customerId, siteId string) string { + return acctest.ConfigCompose( + testAccInstanceConfig_orderableClassDB2(), + fmt.Sprintf(` +resource "aws_db_parameter_group" "test" { + name = "tf-db2-pg-%[1]s" + family = data.aws_rds_engine_version.default.parameter_group_family + + parameter { + name = "rds.ibm_customer_id" + value = %[2]s + apply_method = "immediate" + } + parameter { + name = "rds.ibm_site_id" + value = %[3]s + apply_method = "immediate" + } +} + +resource "aws_db_instance" "test" { + allocated_storage = 100 + db_name = "test" + enabled_cloudwatch_logs_exports = ["diag.log", "notify.log"] + engine = data.aws_rds_orderable_db_instance.test.engine + engine_version = data.aws_rds_orderable_db_instance.test.engine_version + identifier = %[1]q + instance_class = data.aws_rds_orderable_db_instance.test.instance_class + parameter_group_name = aws_db_parameter_group.test.name + password = "avoid-plaintext-passwords" + username = "tfacctest" + skip_final_snapshot = true +} +`, rName, customerId, siteId)) +} + func testAccInstanceConfig_EnabledCloudWatchLogsExports_oracle(rName string) string { return fmt.Sprintf(` data "aws_rds_orderable_db_instance" "test" { diff --git a/website/docs/r/db_instance.html.markdown b/website/docs/r/db_instance.html.markdown index daabbabc13f..fd6f8330c2c 100644 --- a/website/docs/r/db_instance.html.markdown +++ b/website/docs/r/db_instance.html.markdown @@ -320,7 +320,7 @@ for additional read replica constraints. * `deletion_protection` - (Optional) If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to `true`. The default is `false`. * `domain` - (Optional) The ID of the Directory Service Active Directory domain to create the instance in. * `domain_iam_role_name` - (Optional, but required if domain is provided) The name of the IAM role to be used when making API calls to the Directory Service. -* `enabled_cloudwatch_logs_exports` - (Optional) Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. Valid values (depending on `engine`). MySQL and MariaDB: `audit`, `error`, `general`, `slowquery`. PostgreSQL: `postgresql`, `upgrade`. MSSQL: `agent` , `error`. Oracle: `alert`, `audit`, `listener`, `trace`. +* `enabled_cloudwatch_logs_exports` - (Optional) Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. For supported values, see the EnableCloudwatchLogsExports.member.N parameter in [API action CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html). * `engine` - (Required unless a `snapshot_identifier` or `replicate_source_db` is provided) The database engine to use. For supported values, see the Engine parameter in [API action CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html). Note that for Amazon Aurora instances the engine must match the [DB cluster](/docs/providers/aws/r/rds_cluster.html)'s engine'. For information on the difference between the available Aurora MySQL engines see [Comparison between Aurora MySQL 1 and Aurora MySQL 2](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AuroraMySQL.Updates.20180206.html) in the Amazon RDS User Guide. * `engine_version` - (Optional) The engine version to use. If `auto_minor_version_upgrade` is enabled, you can provide a prefix of the version such as `5.7` (for `5.7.10`). The actual engine version used is returned in the attribute `engine_version_actual`, see [Attribute Reference](#attribute-reference) below. For supported values, see the EngineVersion parameter in [API action CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html). Note that for Amazon Aurora instances the engine version must match the [DB cluster](/docs/providers/aws/r/rds_cluster.html)'s engine version'. * `final_snapshot_identifier` - (Optional) The name of your final DB snapshot