Skip to content

Commit

Permalink
feat: Added kms key id and kmy key selector for rds instance
Browse files Browse the repository at this point in the history
Signed-off-by: André Kesser <[email protected]>
  • Loading branch information
André Kesser committed Sep 12, 2022
1 parent afa7390 commit 99141f6
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apis/rds/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,14 @@ type CustomDBInstanceParameters struct {
// ApplyImmediately for each modified parameter and to determine when the changes
// are applied.
ApplyImmediately *bool `json:"applyImmediately,omitempty"`

// KMSKeyIDRef is a reference to a KMS Key used to set KMSKeyID.
// +optional
KMSKeyIDRef *xpv1.Reference `json:"kmsKeyIDRef,omitempty"`

// KMSKeyIDSelector selects a reference to a KMS Key used to set KMSKeyID.
// +optional
KMSKeyIDSelector *xpv1.Selector `json:"kmsKeyIDSelector,omitempty"`
}

// CustomDBInstanceRoleAssociationParameters are custom parameters for the DBInstanceRoleAssociation
Expand Down
14 changes: 14 additions & 0 deletions apis/rds/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,19 @@ func (mg *DBInstance) ResolveReferences(ctx context.Context, c client.Reader) er
mg.Spec.ForProvider.VPCSecurityGroupIDs = mrsp.ResolvedValues
mg.Spec.ForProvider.VPCSecurityGroupIDRefs = mrsp.ResolvedReferences

// Resolve spec.forProvider.kmsKeyID
rsp, err = r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.KMSKeyID),
Reference: mg.Spec.ForProvider.KMSKeyIDRef,
Selector: mg.Spec.ForProvider.KMSKeyIDSelector,
To: reference.To{Managed: &kmsv1alpha1.Key{}, List: &kmsv1alpha1.KeyList{}},
Extract: reference.ExternalName(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.kmsKeyID")
}
mg.Spec.ForProvider.KMSKeyID = reference.ToPtrValue(rsp.ResolvedValue)
mg.Spec.ForProvider.KMSKeyIDRef = rsp.ResolvedReference

return nil
}
10 changes: 10 additions & 0 deletions apis/rds/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions package/crds/rds.aws.crossplane.io_dbinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,81 @@ spec:
RDS Custom for Oracle doesn't use the default key when this
parameter is empty. You must explicitly specify a key."
type: string
kmsKeyIDRef:
description: KMSKeyIDRef is a reference to a KMS Key used to set
KMSKeyID.
properties:
name:
description: Name of the referenced object.
type: string
policy:
description: Policies for referencing.
properties:
resolution:
default: Required
description: Resolution specifies whether resolution of
this reference is required. The default is 'Required',
which means the reconcile will fail if the reference
cannot be resolved. 'Optional' means this reference
will be a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: Resolve specifies when this reference should
be resolved. The default is 'IfNotPresent', which will
attempt to resolve the reference only when the corresponding
field is not present. Use 'Always' to resolve the reference
on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
required:
- name
type: object
kmsKeyIDSelector:
description: KMSKeyIDSelector selects a reference to a KMS Key
used to set KMSKeyID.
properties:
matchControllerRef:
description: MatchControllerRef ensures an object with the
same controller reference as the selecting object is selected.
type: boolean
matchLabels:
additionalProperties:
type: string
description: MatchLabels ensures an object with matching labels
is selected.
type: object
policy:
description: Policies for selection.
properties:
resolution:
default: Required
description: Resolution specifies whether resolution of
this reference is required. The default is 'Required',
which means the reconcile will fail if the reference
cannot be resolved. 'Optional' means this reference
will be a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: Resolve specifies when this reference should
be resolved. The default is 'IfNotPresent', which will
attempt to resolve the reference only when the corresponding
field is not present. Use 'Always' to resolve the reference
on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
type: object
licenseModel:
description: "License model information for this DB instance.
\n Valid values: license-included | bring-your-own-license |
Expand Down

0 comments on commit 99141f6

Please sign in to comment.