diff --git a/apis/rds/v1beta1/zz_generated.deepcopy.go b/apis/rds/v1beta1/zz_generated.deepcopy.go index 97f6dfeef2..362a232727 100644 --- a/apis/rds/v1beta1/zz_generated.deepcopy.go +++ b/apis/rds/v1beta1/zz_generated.deepcopy.go @@ -5167,6 +5167,16 @@ func (in *InstanceInitParameters) DeepCopyInto(out *InstanceInitParameters) { *out = new(bool) **out = **in } + if in.Identifier != nil { + in, out := &in.Identifier, &out.Identifier + *out = new(string) + **out = **in + } + if in.IdentifierPrefix != nil { + in, out := &in.IdentifierPrefix, &out.IdentifierPrefix + *out = new(string) + **out = **in + } if in.InstanceClass != nil { in, out := &in.InstanceClass, &out.InstanceClass *out = new(string) @@ -5532,6 +5542,16 @@ func (in *InstanceObservation) DeepCopyInto(out *InstanceObservation) { *out = new(string) **out = **in } + if in.Identifier != nil { + in, out := &in.Identifier, &out.Identifier + *out = new(string) + **out = **in + } + if in.IdentifierPrefix != nil { + in, out := &in.IdentifierPrefix, &out.IdentifierPrefix + *out = new(string) + **out = **in + } if in.InstanceClass != nil { in, out := &in.InstanceClass, &out.InstanceClass *out = new(string) @@ -5937,6 +5957,16 @@ func (in *InstanceParameters) DeepCopyInto(out *InstanceParameters) { *out = new(bool) **out = **in } + if in.Identifier != nil { + in, out := &in.Identifier, &out.Identifier + *out = new(string) + **out = **in + } + if in.IdentifierPrefix != nil { + in, out := &in.IdentifierPrefix, &out.IdentifierPrefix + *out = new(string) + **out = **in + } if in.InstanceClass != nil { in, out := &in.InstanceClass, &out.InstanceClass *out = new(string) diff --git a/apis/rds/v1beta1/zz_generated.resolvers.go b/apis/rds/v1beta1/zz_generated.resolvers.go index ad685e3579..5e22bbf68b 100644 --- a/apis/rds/v1beta1/zz_generated.resolvers.go +++ b/apis/rds/v1beta1/zz_generated.resolvers.go @@ -551,7 +551,7 @@ func (mg *Instance) ResolveReferences(ctx context.Context, c client.Reader) erro rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.ReplicateSourceDB), - Extract: reference.ExternalName(), + Extract: resource.ExtractParamPath("identifier", false), Reference: mg.Spec.ForProvider.ReplicateSourceDBRef, Selector: mg.Spec.ForProvider.ReplicateSourceDBSelector, To: reference.To{ @@ -593,7 +593,7 @@ func (mg *InstanceRoleAssociation) ResolveReferences(ctx context.Context, c clie rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DBInstanceIdentifier), - Extract: reference.ExternalName(), + Extract: resource.ExtractParamPath("identifier", false), Reference: mg.Spec.ForProvider.DBInstanceIdentifierRef, Selector: mg.Spec.ForProvider.DBInstanceIdentifierSelector, To: reference.To{ @@ -765,7 +765,7 @@ func (mg *ProxyTarget) ResolveReferences(ctx context.Context, c client.Reader) e rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DBInstanceIdentifier), - Extract: reference.ExternalName(), + Extract: resource.ExtractParamPath("identifier", false), Reference: mg.Spec.ForProvider.DBInstanceIdentifierRef, Selector: mg.Spec.ForProvider.DBInstanceIdentifierSelector, To: reference.To{ @@ -807,7 +807,7 @@ func (mg *Snapshot) ResolveReferences(ctx context.Context, c client.Reader) erro rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.DBInstanceIdentifier), - Extract: reference.ExternalName(), + Extract: resource.ExtractParamPath("identifier", false), Reference: mg.Spec.ForProvider.DBInstanceIdentifierRef, Selector: mg.Spec.ForProvider.DBInstanceIdentifierSelector, To: reference.To{ diff --git a/apis/rds/v1beta1/zz_generated_terraformed.go b/apis/rds/v1beta1/zz_generated_terraformed.go index bd65e9c39e..8586079fb8 100755 --- a/apis/rds/v1beta1/zz_generated_terraformed.go +++ b/apis/rds/v1beta1/zz_generated_terraformed.go @@ -256,6 +256,7 @@ func (tr *Instance) LateInitialize(attrs []byte) (bool, error) { } opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} opts = append(opts, resource.WithNameFilter("DBName")) + opts = append(opts, resource.WithNameFilter("IdentifierPrefix")) li := resource.NewGenericLateInitializer(opts...) return li.LateInitialize(&tr.Spec.ForProvider, params) diff --git a/apis/rds/v1beta1/zz_instance_types.go b/apis/rds/v1beta1/zz_instance_types.go index e132dcc2ee..29c1a6317b 100755 --- a/apis/rds/v1beta1/zz_instance_types.go +++ b/apis/rds/v1beta1/zz_instance_types.go @@ -129,6 +129,12 @@ type InstanceInitParameters struct { // accounts is enabled. IAMDatabaseAuthenticationEnabled *bool `json:"iamDatabaseAuthenticationEnabled,omitempty" tf:"iam_database_authentication_enabled,omitempty"` + // Required if restore_to_point_in_time is specified. + Identifier *string `json:"identifier,omitempty" tf:"identifier,omitempty"` + + // Creates a unique identifier beginning with the specified prefix. Conflicts with identifier. + IdentifierPrefix *string `json:"identifierPrefix,omitempty" tf:"identifier_prefix,omitempty"` + // The instance type of the RDS instance. InstanceClass *string `json:"instanceClass,omitempty" tf:"instance_class,omitempty"` @@ -366,6 +372,12 @@ type InstanceObservation struct { // RDS DBI resource ID. ID *string `json:"id,omitempty" tf:"id,omitempty"` + // Required if restore_to_point_in_time is specified. + Identifier *string `json:"identifier,omitempty" tf:"identifier,omitempty"` + + // Creates a unique identifier beginning with the specified prefix. Conflicts with identifier. + IdentifierPrefix *string `json:"identifierPrefix,omitempty" tf:"identifier_prefix,omitempty"` + // The instance type of the RDS instance. InstanceClass *string `json:"instanceClass,omitempty" tf:"instance_class,omitempty"` @@ -674,6 +686,14 @@ type InstanceParameters struct { // +kubebuilder:validation:Optional IAMDatabaseAuthenticationEnabled *bool `json:"iamDatabaseAuthenticationEnabled,omitempty" tf:"iam_database_authentication_enabled,omitempty"` + // Required if restore_to_point_in_time is specified. + // +kubebuilder:validation:Optional + Identifier *string `json:"identifier,omitempty" tf:"identifier,omitempty"` + + // Creates a unique identifier beginning with the specified prefix. Conflicts with identifier. + // +kubebuilder:validation:Optional + IdentifierPrefix *string `json:"identifierPrefix,omitempty" tf:"identifier_prefix,omitempty"` + // The instance type of the RDS instance. // +kubebuilder:validation:Optional InstanceClass *string `json:"instanceClass,omitempty" tf:"instance_class,omitempty"` @@ -828,6 +848,7 @@ type InstanceParameters struct { // PostgreSQL and MySQL Read Replicas // for more information on using Replication. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/rds/v1beta1.Instance + // +crossplane:generate:reference:extractor=github.com/upbound/upjet/pkg/resource.ExtractParamPath("identifier",false) // +kubebuilder:validation:Optional ReplicateSourceDB *string `json:"replicateSourceDb,omitempty" tf:"replicate_source_db,omitempty"` diff --git a/apis/rds/v1beta1/zz_instanceroleassociation_types.go b/apis/rds/v1beta1/zz_instanceroleassociation_types.go index cb3fafc2e8..ceb78bea64 100755 --- a/apis/rds/v1beta1/zz_instanceroleassociation_types.go +++ b/apis/rds/v1beta1/zz_instanceroleassociation_types.go @@ -38,6 +38,7 @@ type InstanceRoleAssociationParameters struct { // DB Instance Identifier to associate with the IAM Role. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/rds/v1beta1.Instance + // +crossplane:generate:reference:extractor=github.com/upbound/upjet/pkg/resource.ExtractParamPath("identifier",false) // +kubebuilder:validation:Optional DBInstanceIdentifier *string `json:"dbInstanceIdentifier,omitempty" tf:"db_instance_identifier,omitempty"` diff --git a/apis/rds/v1beta1/zz_proxytarget_types.go b/apis/rds/v1beta1/zz_proxytarget_types.go index 336c13b337..c17eb67de6 100755 --- a/apis/rds/v1beta1/zz_proxytarget_types.go +++ b/apis/rds/v1beta1/zz_proxytarget_types.go @@ -66,6 +66,7 @@ type ProxyTargetParameters struct { // DB instance identifier. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/rds/v1beta1.Instance + // +crossplane:generate:reference:extractor=github.com/upbound/upjet/pkg/resource.ExtractParamPath("identifier",false) // +kubebuilder:validation:Optional DBInstanceIdentifier *string `json:"dbInstanceIdentifier,omitempty" tf:"db_instance_identifier,omitempty"` diff --git a/apis/rds/v1beta1/zz_snapshot_types.go b/apis/rds/v1beta1/zz_snapshot_types.go index dd17e50c5f..8a5dc39a3a 100755 --- a/apis/rds/v1beta1/zz_snapshot_types.go +++ b/apis/rds/v1beta1/zz_snapshot_types.go @@ -92,6 +92,7 @@ type SnapshotParameters struct { // The DB Instance Identifier from which to take the snapshot. // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/rds/v1beta1.Instance + // +crossplane:generate:reference:extractor=github.com/upbound/upjet/pkg/resource.ExtractParamPath("identifier",false) // +kubebuilder:validation:Optional DBInstanceIdentifier *string `json:"dbInstanceIdentifier,omitempty" tf:"db_instance_identifier,omitempty"` diff --git a/config/externalname.go b/config/externalname.go index faec44d5df..d9222b3f37 100644 --- a/config/externalname.go +++ b/config/externalname.go @@ -570,7 +570,7 @@ var ExternalNameConfigs = map[string]config.ExternalName{ // rds // "aws_rds_cluster": config.ParameterAsIdentifier("cluster_identifier"), - "aws_db_instance": config.ParameterAsIdentifier("identifier"), + "aws_db_instance": config.IdentifierFromProvider, "aws_db_parameter_group": config.NameAsIdentifier, "aws_db_subnet_group": config.NameAsIdentifier, // aws_db_instance_role_association can be imported using the DB Instance Identifier and IAM Role ARN separated by a comma diff --git a/config/rds/config.go b/config/rds/config.go index 14a6f2dbd7..a69e383cb9 100644 --- a/config/rds/config.go +++ b/config/rds/config.go @@ -104,7 +104,7 @@ func Configure(p *config.Provider) { } r.UseAsync = true r.LateInitializer = config.LateInitializer{ - IgnoredFields: []string{"name", "db_name"}, + IgnoredFields: []string{"name", "db_name", "identifier_prefix"}, } r.Sensitive.AdditionalConnectionDetailsFn = func(attr map[string]any) (map[string][]byte, error) { conn := map[string][]byte{} diff --git a/internal/controller/rds/instance/zz_controller.go b/internal/controller/rds/instance/zz_controller.go index c39eb5f273..3236404180 100755 --- a/internal/controller/rds/instance/zz_controller.go +++ b/internal/controller/rds/instance/zz_controller.go @@ -30,7 +30,6 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { for _, i := range o.Provider.Resources["aws_db_instance"].InitializerFns { initializers = append(initializers, i(mgr.GetClient())) } - initializers = append(initializers, managed.NewNameAsExternalName(mgr.GetClient())) cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} if o.SecretStoreConfigGVK != nil { cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) diff --git a/package/crds/rds.aws.upbound.io_instances.yaml b/package/crds/rds.aws.upbound.io_instances.yaml index 75566f6705..1b6144a420 100644 --- a/package/crds/rds.aws.upbound.io_instances.yaml +++ b/package/crds/rds.aws.upbound.io_instances.yaml @@ -297,6 +297,13 @@ spec: description: Specifies whether mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. type: boolean + identifier: + description: Required if restore_to_point_in_time is specified. + type: string + identifierPrefix: + description: Creates a unique identifier beginning with the specified + prefix. Conflicts with identifier. + type: string instanceClass: description: The instance type of the RDS instance. type: string @@ -1068,6 +1075,13 @@ spec: description: Specifies whether mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. type: boolean + identifier: + description: Required if restore_to_point_in_time is specified. + type: string + identifierPrefix: + description: Creates a unique identifier beginning with the specified + prefix. Conflicts with identifier. + type: string instanceClass: description: The instance type of the RDS instance. type: string @@ -1596,6 +1610,13 @@ spec: id: description: RDS DBI resource ID. type: string + identifier: + description: Required if restore_to_point_in_time is specified. + type: string + identifierPrefix: + description: Creates a unique identifier beginning with the specified + prefix. Conflicts with identifier. + type: string instanceClass: description: The instance type of the RDS instance. type: string