diff --git a/apis/rds/v1beta1/zz_clusterinstance_types.go b/apis/rds/v1beta1/zz_clusterinstance_types.go index cf6ab11f52..6e51700b24 100755 --- a/apis/rds/v1beta1/zz_clusterinstance_types.go +++ b/apis/rds/v1beta1/zz_clusterinstance_types.go @@ -51,8 +51,17 @@ type ClusterInstanceInitParameters struct { CustomIAMInstanceProfile *string `json:"customIamInstanceProfile,omitempty" tf:"custom_iam_instance_profile,omitempty"` // Name of the DB parameter group to associate with this instance. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/rds/v1beta1.ParameterGroup DBParameterGroupName *string `json:"dbParameterGroupName,omitempty" tf:"db_parameter_group_name,omitempty"` + // Reference to a ParameterGroup in rds to populate dbParameterGroupName. + // +kubebuilder:validation:Optional + DBParameterGroupNameRef *v1.Reference `json:"dbParameterGroupNameRef,omitempty" tf:"-"` + + // Selector for a ParameterGroup in rds to populate dbParameterGroupName. + // +kubebuilder:validation:Optional + DBParameterGroupNameSelector *v1.Selector `json:"dbParameterGroupNameSelector,omitempty" tf:"-"` + // DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name of the attached aws_rds_cluster. // +crossplane:generate:reference:type=SubnetGroup DBSubnetGroupName *string `json:"dbSubnetGroupName,omitempty" tf:"db_subnet_group_name,omitempty"` @@ -272,9 +281,18 @@ type ClusterInstanceParameters struct { CustomIAMInstanceProfile *string `json:"customIamInstanceProfile,omitempty" tf:"custom_iam_instance_profile,omitempty"` // Name of the DB parameter group to associate with this instance. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/rds/v1beta1.ParameterGroup // +kubebuilder:validation:Optional DBParameterGroupName *string `json:"dbParameterGroupName,omitempty" tf:"db_parameter_group_name,omitempty"` + // Reference to a ParameterGroup in rds to populate dbParameterGroupName. + // +kubebuilder:validation:Optional + DBParameterGroupNameRef *v1.Reference `json:"dbParameterGroupNameRef,omitempty" tf:"-"` + + // Selector for a ParameterGroup in rds to populate dbParameterGroupName. + // +kubebuilder:validation:Optional + DBParameterGroupNameSelector *v1.Selector `json:"dbParameterGroupNameSelector,omitempty" tf:"-"` + // DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name of the attached aws_rds_cluster. // +crossplane:generate:reference:type=SubnetGroup // +kubebuilder:validation:Optional diff --git a/apis/rds/v1beta1/zz_generated.deepcopy.go b/apis/rds/v1beta1/zz_generated.deepcopy.go index b3d198ca34..4606a60b2f 100644 --- a/apis/rds/v1beta1/zz_generated.deepcopy.go +++ b/apis/rds/v1beta1/zz_generated.deepcopy.go @@ -1258,6 +1258,16 @@ func (in *ClusterInstanceInitParameters) DeepCopyInto(out *ClusterInstanceInitPa *out = new(string) **out = **in } + if in.DBParameterGroupNameRef != nil { + in, out := &in.DBParameterGroupNameRef, &out.DBParameterGroupNameRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.DBParameterGroupNameSelector != nil { + in, out := &in.DBParameterGroupNameSelector, &out.DBParameterGroupNameSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.DBSubnetGroupName != nil { in, out := &in.DBSubnetGroupName, &out.DBSubnetGroupName *out = new(string) @@ -1668,6 +1678,16 @@ func (in *ClusterInstanceParameters) DeepCopyInto(out *ClusterInstanceParameters *out = new(string) **out = **in } + if in.DBParameterGroupNameRef != nil { + in, out := &in.DBParameterGroupNameRef, &out.DBParameterGroupNameRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.DBParameterGroupNameSelector != nil { + in, out := &in.DBParameterGroupNameSelector, &out.DBParameterGroupNameSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.DBSubnetGroupName != nil { in, out := &in.DBSubnetGroupName, &out.DBSubnetGroupName *out = new(string) diff --git a/apis/rds/v1beta1/zz_generated.resolvers.go b/apis/rds/v1beta1/zz_generated.resolvers.go index b169ae769c..abbafefd70 100644 --- a/apis/rds/v1beta1/zz_generated.resolvers.go +++ b/apis/rds/v1beta1/zz_generated.resolvers.go @@ -370,6 +370,22 @@ func (mg *ClusterInstance) ResolveReferences(ctx context.Context, c client.Reade mg.Spec.ForProvider.ClusterIdentifier = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.ForProvider.ClusterIdentifierRef = rsp.ResolvedReference + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DBParameterGroupName), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.DBParameterGroupNameRef, + Selector: mg.Spec.ForProvider.DBParameterGroupNameSelector, + To: reference.To{ + List: &ParameterGroupList{}, + Managed: &ParameterGroup{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.DBParameterGroupName") + } + mg.Spec.ForProvider.DBParameterGroupName = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.DBParameterGroupNameRef = rsp.ResolvedReference + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DBSubnetGroupName), Extract: reference.ExternalName(), @@ -434,6 +450,22 @@ func (mg *ClusterInstance) ResolveReferences(ctx context.Context, c client.Reade mg.Spec.InitProvider.ClusterIdentifier = reference.ToPtrValue(rsp.ResolvedValue) mg.Spec.InitProvider.ClusterIdentifierRef = rsp.ResolvedReference + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.DBParameterGroupName), + Extract: reference.ExternalName(), + Reference: mg.Spec.InitProvider.DBParameterGroupNameRef, + Selector: mg.Spec.InitProvider.DBParameterGroupNameSelector, + To: reference.To{ + List: &ParameterGroupList{}, + Managed: &ParameterGroup{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.DBParameterGroupName") + } + mg.Spec.InitProvider.DBParameterGroupName = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.DBParameterGroupNameRef = rsp.ResolvedReference + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.DBSubnetGroupName), Extract: reference.ExternalName(), diff --git a/config/rds/config.go b/config/rds/config.go index 5fa48917c2..fda4033729 100644 --- a/config/rds/config.go +++ b/config/rds/config.go @@ -84,8 +84,8 @@ func Configure(p *config.Provider) { RefFieldName: "SecurityGroupNameRefs", SelectorFieldName: "SecurityGroupNameSelector", } - r.References["parameter_group_name"] = config.Reference{ - Type: "ParameterGroup", + r.References["db_parameter_group_name"] = config.Reference{ + TerraformName: "aws_db_parameter_group", } r.References["db_subnet_group_name"] = config.Reference{ Type: "SubnetGroup", diff --git a/examples/rds/clusterinstance.yaml b/examples/rds/clusterinstance.yaml index 0576893cc4..bef1712ec4 100644 --- a/examples/rds/clusterinstance.yaml +++ b/examples/rds/clusterinstance.yaml @@ -14,6 +14,9 @@ spec: testing.upbound.io/example-name: example-ci engine: aurora-postgresql instanceClass: db.r5.large + dbParameterGroupNameSelector: + matchLabels: + testing.upbound.io/example-name: example-ci --- @@ -49,3 +52,23 @@ metadata: type: Opaque stringData: password: TestPass0! + +--- + +apiVersion: rds.aws.upbound.io/v1beta1 +kind: ParameterGroup +metadata: + annotations: + meta.upbound.io/example-id: rds/v1beta1/clusterinstance + labels: + testing.upbound.io/example-name: example-ci + name: example-parametergroup-ci +spec: + forProvider: + region: us-west-1 + family: aurora-postgresql15 + description: example + parameter: + - name: application_name + value: "example" + applyMethod: immediate diff --git a/package/crds/rds.aws.upbound.io_clusterinstances.yaml b/package/crds/rds.aws.upbound.io_clusterinstances.yaml index 8c2d6876fc..eb9f1b7e01 100644 --- a/package/crds/rds.aws.upbound.io_clusterinstances.yaml +++ b/package/crds/rds.aws.upbound.io_clusterinstances.yaml @@ -173,6 +173,81 @@ spec: description: Name of the DB parameter group to associate with this instance. type: string + dbParameterGroupNameRef: + description: Reference to a ParameterGroup in rds to populate + dbParameterGroupName. + 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 + dbParameterGroupNameSelector: + description: Selector for a ParameterGroup in rds to populate + dbParameterGroupName. + 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 dbSubnetGroupName: description: 'DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name of the attached @@ -588,6 +663,81 @@ spec: description: Name of the DB parameter group to associate with this instance. type: string + dbParameterGroupNameRef: + description: Reference to a ParameterGroup in rds to populate + dbParameterGroupName. + 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 + dbParameterGroupNameSelector: + description: Selector for a ParameterGroup in rds to populate + dbParameterGroupName. + 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 dbSubnetGroupName: description: 'DB subnet group to associate with this DB instance. NOTE: This must match the db_subnet_group_name of the attached