Skip to content

Commit 701f24d

Browse files
authored
crossplane: feat(iam): if else for iam to skip region (#285)
Signed-off-by: haarchri <chhaar30@googlemail.com> Issue #, if available: aws-controllers-k8s/community#1150 Description of changes: skip region for `.APIGroup "iam.aws.crossplane.io"` tested locally with crossplane-contrib/provider-aws#1118 - it is working now By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 8f02d77 commit 701f24d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

templates/crossplane/apis/crd.go.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ import (
1818

1919
// {{ .CRD.Kind }}Parameters defines the desired state of {{ .CRD.Kind }}
2020
type {{ .CRD.Kind }}Parameters struct {
21+
{{- if ne .APIGroup "iam.aws.crossplane.io"}}
2122
// Region is which region the {{ .CRD.Kind }} will be created.
2223
// +kubebuilder:validation:Required
2324
Region string `json:"region"`
25+
{{- end }}
2426
{{- range $fieldName, $field := .CRD.SpecFields }}
2527
{{- if $field.ShapeRef }}
2628
{{ $field.ShapeRef.Documentation }}

templates/crossplane/pkg/controller.go.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ type connector struct {
4040
}
4141

4242
func (c *connector) Connect(ctx context.Context, mg cpresource.Managed) (managed.ExternalClient, error) {
43+
{{- if ne .APIGroup "iam.aws.crossplane.io"}}
4344
cr, ok := mg.(*svcapitypes.{{ .CRD.Names.Camel }})
4445
if !ok {
4546
return nil, errors.New(errUnexpectedObject)
4647
}
4748
sess, err := awsclient.GetConfigV1(ctx, c.kube, mg, cr.Spec.ForProvider.Region)
49+
{{- else}}
50+
sess, err := awsclient.GetConfigV1(ctx, c.kube, mg, awsclient.GlobalRegion)
51+
{{- end}}
4852
if err != nil {
4953
return nil, errors.Wrap(err, errCreateSession)
5054
}

0 commit comments

Comments
 (0)