Repository: crossplane-contrib/provider-aws (go)

Issue:
RDSInstance doesn't set username in `writeConnectionSecretToRef` if you are importing an existing resource

### What happened?
If I import an existing RDSInstance that has been orphaned, the username in the `writeConnectionSecret` is never set because its only ever set in the `create` workflow.


### How can we reproduce it?
Create an RDSInstance using 
```
deletionPolicy: Orphan
writeConnectionSecretToRef:
  name: foobar
  namespace: foobar1
forProvider:
...
   masterUsername: foo
   masterPasswordSecretRef:
     key: pass
     name: secret
     namespace: secret
...    
connectionDetails:
    - fromConnectionSecretKey: endpoint
    - fromConnectionSecretKey: port
    - fromConnectionSecretKey: username
    - fromConnectionSecretKey: password
```

Delete the Secret/manifests

### What environment did it happen in?
Crossplane version: 
V0.46.0




Pull request:
fix(rdsinstance): Updates will now set ResourceCredentialsSecretUserKey in ConnectionDetails if masterUsername is set

### Description of your changes

in rdsInstance when running an update always set `ResourceCredentialsSecretUserKey` in the ConnectionDetails if masterUsername exists.


Fixes #1999

I have:

- [x] Read and followed Crossplane's [contribution process].
- [x] Run `make reviewable test` to ensure this PR is ready for review.

### How has this code been tested

Created an RDSInstance, Deleted it when deletionPolicy = Orphan.
Re-added the RDSInstance, checked the secret contained `username`

[contribution process]: https://git.io/fj2m9


Patch:
diff --git a/pkg/controller/database/rdsinstance/rdsinstance.go b/pkg/controller/database/rdsinstance/rdsinstance.go
index 3028e0ef1..4dc7c7c2f 100644
--- a/pkg/controller/database/rdsinstance/rdsinstance.go
+++ b/pkg/controller/database/rdsinstance/rdsinstance.go
@@ -275,19 +275,21 @@ func (e *external) Update(ctx context.Context, mg resource.Managed) (managed.Ext
 		return managed.ExternalUpdate{}, errors.Wrap(err, errPatchCreationFailed)
 	}
 	modify := rds.GenerateModifyDBInstanceInput(meta.GetExternalName(cr), patch, &rsp.DBInstances[0])
-	var conn managed.ConnectionDetails
+	conn := managed.ConnectionDetails{}
 
 	pwd, changed, err := rds.GetPassword(ctx, e.kube, cr.Spec.ForProvider.MasterPasswordSecretRef, cr.Spec.WriteConnectionSecretToReference)
 	if err != nil {
 		return managed.ExternalUpdate{}, err
 	}
 	if changed {
-		conn = managed.ConnectionDetails{
-			xpv1.ResourceCredentialsSecretPasswordKey: []byte(pwd),
-		}
+		conn[xpv1.ResourceCredentialsSecretPasswordKey] = []byte(pwd)
 		modify.MasterUserPassword = aws.String(pwd)
 	}
 
+	if cr.Spec.ForProvider.MasterUsername != nil {
+		conn[xpv1.ResourceCredentialsSecretUserKey] = []byte(aws.ToString(cr.Spec.ForProvider.MasterUsername))
+	}
+
 	if _, err = e.client.ModifyDBInstance(ctx, modify); err != nil {
 		return managed.ExternalUpdate{}, errorutils.Wrap(err, errModifyFailed)
 	}


Test patch:
diff --git a/pkg/controller/database/rdsinstance/rdsinstance_test.go b/pkg/controller/database/rdsinstance/rdsinstance_test.go
index fce4b36a9..6e211f403 100644
--- a/pkg/controller/database/rdsinstance/rdsinstance_test.go
+++ b/pkg/controller/database/rdsinstance/rdsinstance_test.go
@@ -738,6 +738,9 @@ func TestUpdate(t *testing.T) {
 			},
 			want: want{
 				cr: instance(withTags(map[string]string{"foo": "bar"})),
+				result: managed.ExternalUpdate{
+					ConnectionDetails: managed.ConnectionDetails{},
+				},
 			},
 		},
 		"AutoscaleExcludeStorage": {
@@ -765,6 +768,9 @@ func TestUpdate(t *testing.T) {
 			},
 			want: want{
 				cr: instance(withMaxAllocatedStorage(100), withAllocatedStorage(20)),
+				result: managed.ExternalUpdate{
+					ConnectionDetails: managed.ConnectionDetails{},
+				},
 			},
 		},
 		"AWSManagedBackupRetentionTargetIgnore": {
@@ -796,6 +802,9 @@ func TestUpdate(t *testing.T) {
 			},
 			want: want{
 				cr: instance(withBackupRetentionPeriod(0), withStatusBackupRetentionPeriod(7), withPreferredBackupWindow("x")),
+				result: managed.ExternalUpdate{
+					ConnectionDetails: managed.ConnectionDetails{},
+				},
 			},
 		},
 		"AlreadyModifying": {
@@ -804,6 +813,35 @@ func TestUpdate(t *testing.T) {
 			},
 			want: want{
 				cr: instance(withDBInstanceStatus(v1beta1.RDSInstanceStateModifying)),
+				result: managed.ExternalUpdate{
+					ConnectionDetails: nil,
+				},
+			},
+		},
+		"AddMasterUsernameToConnectionDetails": {
+			args: args{
+				rds: &fake.MockRDSClient{
+					MockModify: func(ctx context.Context, input *awsrds.ModifyDBInstanceInput, opts []func(*awsrds.Options)) (*awsrds.ModifyDBInstanceOutput, error) {
+						return &awsrds.ModifyDBInstanceOutput{}, nil
+					},
+					MockDescribe: func(ctx context.Context, input *awsrds.DescribeDBInstancesInput, opts []func(*awsrds.Options)) (*awsrds.DescribeDBInstancesOutput, error) {
+						return &awsrds.DescribeDBInstancesOutput{
+							DBInstances: []awsrdstypes.DBInstance{{}},
+						}, nil
+					},
+					MockAddTags: func(ctx context.Context, input *awsrds.AddTagsToResourceInput, opts []func(*awsrds.Options)) (*awsrds.AddTagsToResourceOutput, error) {
+						return &awsrds.AddTagsToResourceOutput{}, nil
+					},
+				},
+				cr: instance(withMasterUsername(&masterUsername)),
+			},
+			want: want{
+				cr: instance(withMasterUsername(&masterUsername)),
+				result: managed.ExternalUpdate{
+					ConnectionDetails: managed.ConnectionDetails{
+						xpv1.ResourceCredentialsSecretUserKey: []byte(masterUsername),
+					},
+				},
 			},
 		},
 		"FailedDescribe": {