Skip to content

Commit f088ffa

Browse files
fix(RDS): fix resource sql audit (#7175)
1 parent dfe0dac commit f088ffa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

docs/resources/rds_sql_audit.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ The following arguments are supported:
2929
* `region` - (Optional, String, ForceNew) Specifies the region in which to create the resource.
3030
If omitted, the provider-level region will be used. Changing this parameter will create a new resource.
3131

32-
* `instance_id` - (Required, String, ForceNew) Specifies the ID of the RDS instance.
33-
34-
Changing this parameter will create a new resource.
32+
* `instance_id` - (Required, String, NonUpdatable) Specifies the ID of the RDS instance.
3533

3634
* `keep_days` - (Required, Int) Specifies the number of days for storing audit logs. Value ranges from `1` to `732`.
3735

huaweicloud/services/rds/resource_huaweicloud_rds_sql_audit.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/utils"
2525
)
2626

27+
var sqlAuditNonUpdatableParams = []string{"instance_id"}
28+
2729
// @API RDS GET /v3/{project_id}/instances/{instance_id}/auditlog-policy
2830
// @API RDS PUT /v3/{project_id}/instances/{instance_id}/auditlog-policy
2931
func ResourceSQLAudit() *schema.Resource {
@@ -32,10 +34,13 @@ func ResourceSQLAudit() *schema.Resource {
3234
UpdateContext: resourceSQLAuditUpdate,
3335
ReadContext: resourceSQLAuditRead,
3436
DeleteContext: resourceSQLAuditDelete,
37+
3538
Importer: &schema.ResourceImporter{
3639
StateContext: schema.ImportStatePassthroughContext,
3740
},
3841

42+
CustomizeDiff: config.FlexibleForceNew(sqlAuditNonUpdatableParams),
43+
3944
Timeouts: &schema.ResourceTimeout{
4045
Create: schema.DefaultTimeout(30 * time.Minute),
4146
Update: schema.DefaultTimeout(30 * time.Minute),
@@ -52,7 +57,6 @@ func ResourceSQLAudit() *schema.Resource {
5257
"instance_id": {
5358
Type: schema.TypeString,
5459
Required: true,
55-
ForceNew: true,
5660
Description: `Specifies the ID of the RDS instance.`,
5761
},
5862
"keep_days": {
@@ -74,6 +78,12 @@ func ResourceSQLAudit() *schema.Resource {
7478
Description: `Specifies whether the historical audit logs will be reserved for some time when SQL
7579
audit is disabled.`,
7680
},
81+
"enable_force_new": {
82+
Type: schema.TypeString,
83+
Optional: true,
84+
ValidateFunc: validation.StringInSlice([]string{"true", "false"}, false),
85+
Description: utils.SchemaDesc("", utils.SchemaDescInput{Internal: true}),
86+
},
7787
},
7888
}
7989
}

0 commit comments

Comments
 (0)