From 44755d32c4ff9102a2bbd16183a20740ce4453a9 Mon Sep 17 00:00:00 2001 From: "Charel Baum (external expert on behalf of DB Netz AG)" Date: Mon, 7 Aug 2023 14:53:12 +0200 Subject: [PATCH] fix(database)!: remove cloudwatchLogsExportConfiguration Signed-off-by: Charel Baum (external expert on behalf of DB Netz AG) --- apis/database/v1beta1/rdsinstance_types.go | 32 +--- .../database/v1beta1/zz_generated.deepcopy.go | 35 +--- ...tabase.aws.crossplane.io_rdsinstances.yaml | 25 ++- pkg/clients/database/rds.go | 76 +++++++-- pkg/clients/database/rds_test.go | 149 ++++++++---------- pkg/controller/database/rdsinstance.go | 2 +- 6 files changed, 155 insertions(+), 164 deletions(-) diff --git a/apis/database/v1beta1/rdsinstance_types.go b/apis/database/v1beta1/rdsinstance_types.go index d26968ede1..0f64a172d8 100644 --- a/apis/database/v1beta1/rdsinstance_types.go +++ b/apis/database/v1beta1/rdsinstance_types.go @@ -57,24 +57,6 @@ type ProcessorFeature struct { Value string `json:"value"` } -// CloudwatchLogsExportConfiguration is the configuration setting for the log types to be enabled for export to CloudWatch -// Logs for a specific DB instance or DB cluster. -// The EnableLogTypes and DisableLogTypes arrays determine which logs will be -// exported (or not exported) to CloudWatch Logs. The values within these arrays -// depend on the DB engine being used. For more information, see Publishing -// Database Logs to Amazon CloudWatch Logs (http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html#USER_LogAccess.Procedural.UploadtoCloudWatch) -// in the Amazon RDS User Guide. -// Please also see https://docs.aws.amazon.com/goto/WebAPI/rds-2014-10-31/CloudwatchLogsExportConfiguration -type CloudwatchLogsExportConfiguration struct { - // DisableLogTypes is the list of log types to disable. - // +immutable - DisableLogTypes []string `json:"disableLogTypes,omitempty"` - - // EnableLogTypes is the list of log types to enable. - // +immutable - EnableLogTypes []string `json:"enableLogTypes,omitempty"` -} - // ScalingConfiguration contains the scaling configuration of an Aurora Serverless DB cluster. // For more information, see Using Amazon Aurora Serverless (http://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html) // in the Amazon Aurora User Guide. @@ -413,7 +395,6 @@ type RDSInstanceParameters struct { // Logs. The values in the list depend on the DB engine being used. For more // information, see Publishing Database Logs to Amazon CloudWatch Logs (http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html#USER_LogAccess.Procedural.UploadtoCloudWatch) // in the Amazon Relational Database Service User Guide. - // +immutable // +optional EnableCloudwatchLogsExports []string `json:"enableCloudwatchLogsExports,omitempty"` @@ -793,12 +774,6 @@ type RDSInstanceParameters struct { // +optional ApplyModificationsImmediately *bool `json:"applyModificationsImmediately,omitempty"` - // CloudwatchLogsExportConfiguration is the configuration setting for the log types to be enabled for export to CloudWatch - // Logs for a specific DB instance. - // +immutable - // +optional - CloudwatchLogsExportConfiguration *CloudwatchLogsExportConfiguration `json:"cloudwatchLogsExportConfiguration,omitempty"` - // DBParameterGroupName is the name of the DB parameter group to associate with this DB instance. If // this argument is omitted, the default DBParameterGroup for the specified // engine is used. @@ -1166,6 +1141,13 @@ type RDSInstanceObservation struct { // InstanceCreateTime provides the date and time the DB instance was created. InstanceCreateTime *metav1.Time `json:"instanceCreateTime,omitempty"` + // A list of log types that this DB instance is configured to export to CloudWatch + // Logs. Log types vary by DB engine. For information about the log types for each + // DB engine, see Amazon RDS Database Log Files + // (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html) in + // the Amazon RDS User Guide. + EnabledCloudwatchLogsExports []string `json:"enabledCloudwatchLogsExports,omitempty"` + // Endpoint specifies the connection endpoint. Endpoint Endpoint `json:"endpoint,omitempty"` diff --git a/apis/database/v1beta1/zz_generated.deepcopy.go b/apis/database/v1beta1/zz_generated.deepcopy.go index ab97204f83..4da7f38d27 100644 --- a/apis/database/v1beta1/zz_generated.deepcopy.go +++ b/apis/database/v1beta1/zz_generated.deepcopy.go @@ -41,31 +41,6 @@ func (in *AvailabilityZone) DeepCopy() *AvailabilityZone { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *CloudwatchLogsExportConfiguration) DeepCopyInto(out *CloudwatchLogsExportConfiguration) { - *out = *in - if in.DisableLogTypes != nil { - in, out := &in.DisableLogTypes, &out.DisableLogTypes - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.EnableLogTypes != nil { - in, out := &in.EnableLogTypes, &out.EnableLogTypes - *out = make([]string, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudwatchLogsExportConfiguration. -func (in *CloudwatchLogsExportConfiguration) DeepCopy() *CloudwatchLogsExportConfiguration { - if in == nil { - return nil - } - out := new(CloudwatchLogsExportConfiguration) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DBInstanceStatusInfo) DeepCopyInto(out *DBInstanceStatusInfo) { *out = *in @@ -508,6 +483,11 @@ func (in *RDSInstanceObservation) DeepCopyInto(out *RDSInstanceObservation) { in, out := &in.InstanceCreateTime, &out.InstanceCreateTime *out = (*in).DeepCopy() } + if in.EnabledCloudwatchLogsExports != nil { + in, out := &in.EnabledCloudwatchLogsExports, &out.EnabledCloudwatchLogsExports + *out = make([]string, len(*in)) + copy(*out, *in) + } out.Endpoint = in.Endpoint if in.EngineVersion != nil { in, out := &in.EngineVersion, &out.EngineVersion @@ -811,11 +791,6 @@ func (in *RDSInstanceParameters) DeepCopyInto(out *RDSInstanceParameters) { *out = new(bool) **out = **in } - if in.CloudwatchLogsExportConfiguration != nil { - in, out := &in.CloudwatchLogsExportConfiguration, &out.CloudwatchLogsExportConfiguration - *out = new(CloudwatchLogsExportConfiguration) - (*in).DeepCopyInto(*out) - } if in.DBParameterGroupName != nil { in, out := &in.DBParameterGroupName, &out.DBParameterGroupName *out = new(string) diff --git a/package/crds/database.aws.crossplane.io_rdsinstances.yaml b/package/crds/database.aws.crossplane.io_rdsinstances.yaml index b645f036ed..06f16a3778 100644 --- a/package/crds/database.aws.crossplane.io_rdsinstances.yaml +++ b/package/crds/database.aws.crossplane.io_rdsinstances.yaml @@ -167,22 +167,6 @@ spec: engines, Amazon Aurora Not applicable. The character set is managed by the DB cluster. For more information, see CreateDBCluster. type: string - cloudwatchLogsExportConfiguration: - description: CloudwatchLogsExportConfiguration is the configuration - setting for the log types to be enabled for export to CloudWatch - Logs for a specific DB instance. - properties: - disableLogTypes: - description: DisableLogTypes is the list of log types to disable. - items: - type: string - type: array - enableLogTypes: - description: EnableLogTypes is the list of log types to enable. - items: - type: string - type: array - type: object copyTagsToSnapshot: description: CopyTagsToSnapshot should be true to copy all tags from the DB instance to snapshots of the DB instance, and otherwise @@ -1517,6 +1501,15 @@ spec: type: string type: object type: array + enabledCloudwatchLogsExports: + description: A list of log types that this DB instance is configured + to export to CloudWatch Logs. Log types vary by DB engine. For + information about the log types for each DB engine, see Amazon + RDS Database Log Files (https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.html) + in the Amazon RDS User Guide. + items: + type: string + type: array endpoint: description: Endpoint specifies the connection endpoint. properties: diff --git a/pkg/clients/database/rds.go b/pkg/clients/database/rds.go index d92a1f2250..5116584e77 100644 --- a/pkg/clients/database/rds.go +++ b/pkg/clients/database/rds.go @@ -359,7 +359,7 @@ func CreatePatch(in *rdstypes.DBInstance, target *v1beta1.RDSInstanceParameters) } // GenerateModifyDBInstanceInput from RDSInstanceSpec -func GenerateModifyDBInstanceInput(name string, p *v1beta1.RDSInstanceParameters) *rds.ModifyDBInstanceInput { +func GenerateModifyDBInstanceInput(name string, p *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance) *rds.ModifyDBInstanceInput { // NOTE(muvaf): MasterUserPassword is not used here. So, password is set once // and kept that way. // NOTE(muvaf): Change of DBInstanceIdentifier is supported by AWS but @@ -411,12 +411,11 @@ func GenerateModifyDBInstanceInput(name string, p *v1beta1.RDSInstanceParameters } } } - if p.CloudwatchLogsExportConfiguration != nil { - m.CloudwatchLogsExportConfiguration = &rdstypes.CloudwatchLogsExportConfiguration{ - DisableLogTypes: p.CloudwatchLogsExportConfiguration.DisableLogTypes, - EnableLogTypes: p.CloudwatchLogsExportConfiguration.EnableLogTypes, - } - } + + m.CloudwatchLogsExportConfiguration = generateCloudWatchExportConfiguration( + p.EnableCloudwatchLogsExports, + db.EnabledCloudwatchLogsExports) + return m } @@ -431,6 +430,7 @@ func GenerateObservation(db rdstypes.DBInstance) v1beta1.RDSInstanceObservation DBInstanceArn: aws.ToString(db.DBInstanceArn), DBInstancePort: int(db.DbInstancePort), DBResourceID: aws.ToString(db.DbiResourceId), + EnabledCloudwatchLogsExports: db.EnabledCloudwatchLogsExports, EnhancedMonitoringResourceArn: aws.ToString(db.EnhancedMonitoringResourceArn), PerformanceInsightsEnabled: aws.ToBool(db.PerformanceInsightsEnabled), ReadReplicaDBClusterIdentifiers: db.ReadReplicaDBClusterIdentifiers, @@ -621,9 +621,6 @@ func LateInitialize(in *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance) if aws.ToString(in.DBSubnetGroupName) == "" && db.DBSubnetGroup != nil { in.DBSubnetGroupName = db.DBSubnetGroup.DBSubnetGroupName } - if len(in.EnableCloudwatchLogsExports) == 0 && len(db.EnabledCloudwatchLogsExports) != 0 { - in.EnableCloudwatchLogsExports = db.EnabledCloudwatchLogsExports - } if len(in.ProcessorFeatures) == 0 && len(db.ProcessorFeatures) != 0 { in.ProcessorFeatures = make([]v1beta1.ProcessorFeature, len(db.ProcessorFeatures)) for i, val := range db.ProcessorFeatures { @@ -678,13 +675,21 @@ func IsUpToDate(ctx context.Context, kube client.Client, r *v1beta1.RDSInstance, cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "AllowMajorVersionUpgrade"), cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "MasterPasswordSecretRef"), cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "OptionGroupName"), + cmpopts.IgnoreFields(v1beta1.RDSInstanceParameters{}, "EnableCloudwatchLogsExports"), ) engineVersionChanged := !isEngineVersionUpToDate(r, db) optionGroupChanged := !isOptionGroupUpToDate(r, db) - if diff == "" && !pwdChanged && !engineVersionChanged && !optionGroupChanged { + cloudwatchLogsExportChanged := false + // only check CloudwatchLogsExports if there are no pending cloudwatchlogs exports (ignores the apply immediately setting) + // (to avoid: "api error InvalidParameterCombination: You cannot configure CloudWatch Logs while a previous configuration is in progress.") + if db.PendingModifiedValues != nil && db.PendingModifiedValues.PendingCloudwatchLogsExports == nil { + cloudwatchLogsExportChanged = !areSameElements(r.Spec.ForProvider.EnableCloudwatchLogsExports, db.EnabledCloudwatchLogsExports) + } + + if diff == "" && !pwdChanged && !engineVersionChanged && !optionGroupChanged && !cloudwatchLogsExportChanged { return true, "", nil } @@ -780,3 +785,52 @@ func GetConnectionDetails(in v1beta1.RDSInstance) managed.ConnectionDetails { xpv1.ResourceCredentialsSecretPortKey: []byte(strconv.Itoa(in.Status.AtProvider.Endpoint.Port)), } } + +func generateCloudWatchExportConfiguration(spec, current []string) *rdstypes.CloudwatchLogsExportConfiguration { + toEnable := []string{} + toDisable := []string{} + + currentMap := make(map[string]struct{}, len(current)) + for _, currentID := range current { + currentMap[currentID] = struct{}{} + } + + specMap := make(map[string]struct{}, len(spec)) + for _, specID := range spec { + specMap[specID] = struct{}{} + + if _, exists := currentMap[specID]; !exists { + toEnable = append(toEnable, specID) + } + } + + for _, currentID := range current { + if _, exists := specMap[currentID]; !exists { + toDisable = append(toDisable, currentID) + } + } + + return &rdstypes.CloudwatchLogsExportConfiguration{ + EnableLogTypes: toEnable, + DisableLogTypes: toDisable, + } +} + +func areSameElements(a1, a2 []string) bool { + if len(a1) != len(a2) { + return false + } + + m2 := make(map[string]struct{}, len(a2)) + for _, s2 := range a2 { + m2[s2] = struct{}{} + } + + for _, s1 := range a1 { + if _, exists := m2[s1]; !exists { + return false + } + } + + return true +} diff --git a/pkg/clients/database/rds_test.go b/pkg/clients/database/rds_test.go index 6fe72c91a2..9803a118a0 100644 --- a/pkg/clients/database/rds_test.go +++ b/pkg/clients/database/rds_test.go @@ -45,42 +45,44 @@ import ( ) var ( - allocatedStorage int32 = 20 - address = "address" - arn = "my:arn" - az = "az" - characterSetName = "utf8" - cloudwatchExports = []string{"test"} - clusterName = "testCluster" - dbName = "example-name" - description = "testDescription" - domain = "domain" - engine = "5.6.41" - falseFlag = false - instanceClass = "class" - kmsID = "kms" - monitoring = 3 - monitoring32 = int32(monitoring) - multiAZ = true - name = "testName" - port = 123 - port32 = int32(port) - resourceID = "resource" - retention = 2 - retention32 = int32(retention) - status = "testStatus" - storage = 1 - storage32 = int32(storage) - storageType = "storageType" - tier = 4 - tier32 = int32(tier) - trueFlag = true - truncEngine = "5.6" - username = "username" - value = "testValue" - vpc = "vpc" - window = "window" - zone = "zone" + allocatedStorage int32 = 20 + address = "address" + arn = "my:arn" + az = "az" + characterSetName = "utf8" + clusterName = "testCluster" + dbName = "example-name" + description = "testDescription" + domain = "domain" + enableCloudwatchExports = []string{"test"} + enabledCloudwatchExports = []string{"test"} + enabledCloudwatchExportsNone = []string{} + engine = "5.6.41" + falseFlag = false + instanceClass = "class" + kmsID = "kms" + monitoring = 3 + monitoring32 = int32(monitoring) + multiAZ = true + name = "testName" + port = 123 + port32 = int32(port) + resourceID = "resource" + retention = 2 + retention32 = int32(retention) + status = "testStatus" + storage = 1 + storage32 = int32(storage) + storageType = "storageType" + tier = 4 + tier32 = int32(tier) + trueFlag = true + truncEngine = "5.6" + username = "username" + value = "testValue" + vpc = "vpc" + window = "window" + zone = "zone" secretNamespace = "crossplane-system" connectionSecretName = "my-little-secret" @@ -653,8 +655,8 @@ func TestGenerateObservation(t *testing.T) { StorageType: &storageType, } pendingCloudwatch := rdstypes.PendingCloudwatchLogsExports{ - LogTypesToDisable: cloudwatchExports, - LogTypesToEnable: cloudwatchExports, + LogTypesToDisable: nil, + LogTypesToEnable: enableCloudwatchExports, } pendingModifiedValues.PendingCloudwatchLogsExports = &pendingCloudwatch pendingModifiedValues.ProcessorFeatures = []rdstypes.ProcessorFeature{{ @@ -674,6 +676,7 @@ func TestGenerateObservation(t *testing.T) { DbInstancePort: port32, DbiResourceId: &resourceID, BackupRetentionPeriod: retention32, + EnabledCloudwatchLogsExports: enabledCloudwatchExports, EnhancedMonitoringResourceArn: &arn, PerformanceInsightsEnabled: &trueFlag, ReadReplicaDBClusterIdentifiers: replicaClusters, @@ -730,6 +733,7 @@ func TestGenerateObservation(t *testing.T) { DomainMemberships: []v1beta1.DomainMembership{{Domain: domain, FQDN: name, IAMRoleName: name, Status: status}}, InstanceCreateTime: &metav1.Time{Time: createTime}, Endpoint: v1beta1.Endpoint{Port: port, HostedZoneID: zone, Address: address}, + EnabledCloudwatchLogsExports: enabledCloudwatchExports, EnhancedMonitoringResourceArn: arn, LatestRestorableTime: &metav1.Time{Time: lastRestoreTime}, OptionGroupMemberships: []v1beta1.OptionGroupMembership{{OptionGroupName: name, Status: status}}, @@ -745,8 +749,8 @@ func TestGenerateObservation(t *testing.T) { Port: port, StorageType: storageType, PendingCloudwatchLogsExports: v1beta1.PendingCloudwatchLogsExports{ - LogTypesToDisable: cloudwatchExports, - LogTypesToEnable: cloudwatchExports, + LogTypesToDisable: nil, + LogTypesToEnable: enableCloudwatchExports, }, ProcessorFeatures: []v1beta1.ProcessorFeature{{Name: name, Value: value}}, }, @@ -933,7 +937,7 @@ func TestLateInitialize(t *testing.T) { Timezone: &zone, DBSecurityGroups: []rdstypes.DBSecurityGroupMembership{{DBSecurityGroupName: &name, Status: &status}}, DBSubnetGroup: &subnetGroup, - EnabledCloudwatchLogsExports: cloudwatchExports, + EnabledCloudwatchLogsExports: enabledCloudwatchExports, ProcessorFeatures: []rdstypes.ProcessorFeature{{ Name: &name, Value: &value, @@ -979,7 +983,7 @@ func TestLateInitialize(t *testing.T) { Timezone: &zone, DBSecurityGroups: []string{name}, DBSubnetGroupName: subnetGroup.DBSubnetGroupName, - EnableCloudwatchLogsExports: cloudwatchExports, + EnableCloudwatchLogsExports: nil, ProcessorFeatures: []v1beta1.ProcessorFeature{{ Name: name, Value: value, @@ -1044,26 +1048,6 @@ func TestLateInitialize(t *testing.T) { StorageEncrypted: &falseFlag, }, }, - "CloudwatchExportsNotOverwritten": { - rds: rdstypes.DBInstance{ - EnabledCloudwatchLogsExports: cloudwatchExports, - }, - params: v1beta1.RDSInstanceParameters{ - EnableCloudwatchLogsExports: []string{"newExport"}, - }, - want: v1beta1.RDSInstanceParameters{ - EnableCloudwatchLogsExports: []string{"newExport"}, - - AutoMinorVersionUpgrade: &falseFlag, - BackupRetentionPeriod: new(int), - CopyTagsToSnapshot: &falseFlag, - DeletionProtection: &falseFlag, - EnableIAMDatabaseAuthentication: &falseFlag, - MultiAZ: &falseFlag, - PubliclyAccessible: &falseFlag, - StorageEncrypted: &falseFlag, - }, - }, "ProcessorFeaturesNotOverwritten": { rds: rdstypes.DBInstance{ ProcessorFeatures: []rdstypes.ProcessorFeature{{ @@ -1174,17 +1158,11 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { emptyName := "emptyProcessor" iamRole := "iamRole" vpcIds := []string{name} - rdsCloudwatchLogsExportConfig := rdstypes.CloudwatchLogsExportConfiguration{ - DisableLogTypes: cloudwatchExports, - EnableLogTypes: cloudwatchExports, - } - cloudwatchLogsExportConfig := v1beta1.CloudwatchLogsExportConfiguration{ - DisableLogTypes: cloudwatchExports, - EnableLogTypes: cloudwatchExports, - } + cases := map[string]struct { name string params v1beta1.RDSInstanceParameters + db rdstypes.DBInstance want rds.ModifyDBInstanceInput }{ "AllFields": { @@ -1200,7 +1178,6 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { BackupRetentionPeriod: &retention, CACertificateIdentifier: &name, CharacterSetName: &name, - CloudwatchLogsExportConfiguration: &cloudwatchLogsExportConfig, CopyTagsToSnapshot: &trueFlag, DBClusterIdentifier: &clusterName, DBName: &name, @@ -1208,6 +1185,7 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { DeletionProtection: &trueFlag, Domain: &domain, DomainIAMRoleName: &iamRole, + EnableCloudwatchLogsExports: enableCloudwatchExports, EnableIAMDatabaseAuthentication: &trueFlag, EnablePerformanceInsights: &trueFlag, IOPS: &storage, @@ -1230,7 +1208,6 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { Timezone: &zone, DBSecurityGroups: dbSecurityGroups, DBSubnetGroupName: &name, - EnableCloudwatchLogsExports: cloudwatchExports, ProcessorFeatures: []v1beta1.ProcessorFeature{{ Name: name, Value: value, @@ -1239,14 +1216,21 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { EngineVersion: &engine, UseDefaultProcessorFeatures: &trueFlag, }, + db: rdstypes.DBInstance{ + EnabledCloudwatchLogsExports: enabledCloudwatchExportsNone, + }, want: rds.ModifyDBInstanceInput{ - DBInstanceIdentifier: &allFieldsName, - AllocatedStorage: &storage32, - AllowMajorVersionUpgrade: trueFlag, - ApplyImmediately: trueFlag, - AutoMinorVersionUpgrade: &trueFlag, - BackupRetentionPeriod: &retention32, - CACertificateIdentifier: &name, + DBInstanceIdentifier: &allFieldsName, + AllocatedStorage: &storage32, + AllowMajorVersionUpgrade: trueFlag, + ApplyImmediately: trueFlag, + AutoMinorVersionUpgrade: &trueFlag, + BackupRetentionPeriod: &retention32, + CACertificateIdentifier: &name, + CloudwatchLogsExportConfiguration: &rdstypes.CloudwatchLogsExportConfiguration{ + DisableLogTypes: []string{}, + EnableLogTypes: enableCloudwatchExports, + }, CopyTagsToSnapshot: &trueFlag, DBInstanceClass: &instanceClass, DBParameterGroupName: &name, @@ -1278,7 +1262,6 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { Name: &name, Value: &value, }}, - CloudwatchLogsExportConfiguration: &rdsCloudwatchLogsExportConfig, }, }, "Empty": { @@ -1286,13 +1269,17 @@ func TestGenerateModifyDBInstanceInput(t *testing.T) { params: v1beta1.RDSInstanceParameters{}, want: rds.ModifyDBInstanceInput{ DBInstanceIdentifier: &emptyName, + CloudwatchLogsExportConfiguration: &rdstypes.CloudwatchLogsExportConfiguration{ + DisableLogTypes: []string{}, + EnableLogTypes: []string{}, + }, }, }, } for name, tc := range cases { t.Run(name, func(t *testing.T) { - got := GenerateModifyDBInstanceInput(tc.name, &tc.params) + got := GenerateModifyDBInstanceInput(tc.name, &tc.params, &tc.db) if diff := cmp.Diff(&tc.want, got, cmpopts.IgnoreTypes(document.NoSerde{})); diff != "" { t.Errorf("r: -want, +got:\n%s", diff) } diff --git a/pkg/controller/database/rdsinstance.go b/pkg/controller/database/rdsinstance.go index c701c4a2e2..0f88cb2a9a 100644 --- a/pkg/controller/database/rdsinstance.go +++ b/pkg/controller/database/rdsinstance.go @@ -245,7 +245,7 @@ func (e *external) Update(ctx context.Context, mg resource.Managed) (managed.Ext if err != nil { return managed.ExternalUpdate{}, errors.Wrap(err, errPatchCreationFailed) } - modify := rds.GenerateModifyDBInstanceInput(meta.GetExternalName(cr), patch) + modify := rds.GenerateModifyDBInstanceInput(meta.GetExternalName(cr), patch, &rsp.DBInstances[0]) var conn managed.ConnectionDetails pwd, changed, err := rds.GetPassword(ctx, e.kube, cr.Spec.ForProvider.MasterPasswordSecretRef, cr.Spec.WriteConnectionSecretToReference)