Skip to content

Commit 8d79e51

Browse files
committed
Add externalname func for rds instance state and bump upjet
Signed-off-by: Fatih Türken <turkenf@gmail.com>
1 parent 1322ea2 commit 8d79e51

8 files changed

Lines changed: 145 additions & 4 deletions

File tree

apis/rds/v1beta1/zz_generated.deepcopy.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/rds/v1beta1/zz_generated.resolvers.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/rds/v1beta1/zz_instancestate_types.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/externalname.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ var TerraformPluginFrameworkExternalNameConfigs = map[string]config.ExternalName
112112
// rds
113113
//
114114
// aws_rds_instance_state import format: rdsInstanceId-12345678
115-
"aws_rds_instance_state": config.TemplatedStringAsIdentifier("", "{{ .parameters.identifier }}"),
115+
"aws_rds_instance_state": rdsInstanceState(),
116116

117117
// s3
118118
//
@@ -3315,3 +3315,19 @@ func genericARNTemplate(service string, resource string, elideRegion bool) strin
33153315
}
33163316
return fmt.Sprintf("arn:{{ .setup.client_metadata.partition }}:%s:%s:{{ .setup.client_metadata.account_id }}:%s", service, region, resource)
33173317
}
3318+
3319+
func rdsInstanceState() config.ExternalName {
3320+
e := config.IdentifierFromProvider
3321+
e.GetExternalNameFn = func(tfstate map[string]any) (string, error) {
3322+
id, ok := tfstate["identifier"]
3323+
if !ok {
3324+
return "", errors.New("identifier field missing from tfstate")
3325+
}
3326+
idStr, ok := id.(string)
3327+
if !ok {
3328+
return "", errors.New("identifier field must be a string")
3329+
}
3330+
return idStr, nil
3331+
}
3332+
return e
3333+
}

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,5 @@ require (
442442
replace github.com/hashicorp/terraform-plugin-log => github.com/gdavison/terraform-plugin-log v0.0.0-20230928191232-6c653d8ef8fb
443443

444444
replace github.com/hashicorp/terraform-provider-aws => github.com/upbound/terraform-provider-aws v0.0.0-20250506092832-b90a2e906d79
445+
446+
replace github.com/crossplane/upjet => github.com/turkenf/upjet v0.0.0-20250612105126-656b1c9d10b0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,6 @@ github.com/crossplane/crossplane-runtime v1.17.0 h1:y+GvxPT1M9s8BKt2AeZJdd2d6pg2
580580
github.com/crossplane/crossplane-runtime v1.17.0/go.mod h1:vtglCrnnbq2HurAk9yLHa4qS0bbnCxaKL7C21cQcB/0=
581581
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y=
582582
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0=
583-
github.com/crossplane/upjet v1.5.1 h1:CuVYThNa6mxenXZ1O/bHEiTYnMWrY2KiAurCJiqELvA=
584-
github.com/crossplane/upjet v1.5.1/go.mod h1:F2u9XwKNzxM+myfS1Opjnc6a5E1N2PC7Mytbkavawvs=
585583
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
586584
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
587585
github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw=
@@ -868,6 +866,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
868866
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
869867
github.com/tmccombs/hcl2json v0.3.3 h1:+DLNYqpWE0CsOQiEZu+OZm5ZBImake3wtITYxQ8uLFQ=
870868
github.com/tmccombs/hcl2json v0.3.3/go.mod h1:Y2chtz2x9bAeRTvSibVRVgbLJhLJXKlUeIvjeVdnm4w=
869+
github.com/turkenf/upjet v0.0.0-20250612105126-656b1c9d10b0 h1:Tc3oe4i2WeXkExz93HJNNUxM0FUJvyZp3sdNjUhjmL4=
870+
github.com/turkenf/upjet v0.0.0-20250612105126-656b1c9d10b0/go.mod h1:F2u9XwKNzxM+myfS1Opjnc6a5E1N2PC7Mytbkavawvs=
871871
github.com/upbound/terraform-provider-aws v0.0.0-20250506092832-b90a2e906d79 h1:hgkIgehWzuWaZ5jIT/zQqN2zdPZEGjEO7jVQdArb/b0=
872872
github.com/upbound/terraform-provider-aws v0.0.0-20250506092832-b90a2e906d79/go.mod h1:B7SdSRSmPRFkPECx8/XlhVDovQuzdg34iQzuLUFqgs8=
873873
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=

internal/controller/rds/instancestate/zz_controller.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/crds/rds.aws.upbound.io_instancestates.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,83 @@ spec:
173173
for example because of an external controller is managing them, like an
174174
autoscaler.
175175
properties:
176+
identifier:
177+
description: DB Instance Identifier
178+
type: string
179+
identifierRef:
180+
description: Reference to a Instance in rds to populate identifier.
181+
properties:
182+
name:
183+
description: Name of the referenced object.
184+
type: string
185+
policy:
186+
description: Policies for referencing.
187+
properties:
188+
resolution:
189+
default: Required
190+
description: |-
191+
Resolution specifies whether resolution of this reference is required.
192+
The default is 'Required', which means the reconcile will fail if the
193+
reference cannot be resolved. 'Optional' means this reference will be
194+
a no-op if it cannot be resolved.
195+
enum:
196+
- Required
197+
- Optional
198+
type: string
199+
resolve:
200+
description: |-
201+
Resolve specifies when this reference should be resolved. The default
202+
is 'IfNotPresent', which will attempt to resolve the reference only when
203+
the corresponding field is not present. Use 'Always' to resolve the
204+
reference on every reconcile.
205+
enum:
206+
- Always
207+
- IfNotPresent
208+
type: string
209+
type: object
210+
required:
211+
- name
212+
type: object
213+
identifierSelector:
214+
description: Selector for a Instance in rds to populate identifier.
215+
properties:
216+
matchControllerRef:
217+
description: |-
218+
MatchControllerRef ensures an object with the same controller reference
219+
as the selecting object is selected.
220+
type: boolean
221+
matchLabels:
222+
additionalProperties:
223+
type: string
224+
description: MatchLabels ensures an object with matching labels
225+
is selected.
226+
type: object
227+
policy:
228+
description: Policies for selection.
229+
properties:
230+
resolution:
231+
default: Required
232+
description: |-
233+
Resolution specifies whether resolution of this reference is required.
234+
The default is 'Required', which means the reconcile will fail if the
235+
reference cannot be resolved. 'Optional' means this reference will be
236+
a no-op if it cannot be resolved.
237+
enum:
238+
- Required
239+
- Optional
240+
type: string
241+
resolve:
242+
description: |-
243+
Resolve specifies when this reference should be resolved. The default
244+
is 'IfNotPresent', which will attempt to resolve the reference only when
245+
the corresponding field is not present. Use 'Always' to resolve the
246+
reference on every reconcile.
247+
enum:
248+
- Always
249+
- IfNotPresent
250+
type: string
251+
type: object
252+
type: object
176253
state:
177254
description: Configured state of the DB Instance. Valid values
178255
are available and stopped.

0 commit comments

Comments
 (0)