Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the ability to create the same ECR Repository in multiple regions #1977

Closed
brandocomando opened this issue Dec 14, 2023 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@brandocomando
Copy link

brandocomando commented Dec 14, 2023

What problem are you facing?

Currently it is not possible to manage ECR repositories in multiple regions with the same name from a single k8s cluster.
I feel it is a very common configuration for teams operating in multiple aws regions to have ECR replication enabled so that images pushed to one region get replicated to other regions.

Because the name of the ECR repo is tied to the name of the k8s object I cant create the same repo in multiple regions.

How could Crossplane help solve your problem?

I'm thinking the best path forward would be to add a new property to the forProvider object called something like awsName.

This would allow you to have 2 objects with different names and regions, but the same awsName resulting in the same repository being created in multiple regions.

for example:

apiVersion: ecr.aws.crossplane.io/v1beta1
kind: Repository
metadata:
  name: repo1-us-east-2
spec:
  forProvider:
    awsName: repo1
    region: us-east-2
---
apiVersion: ecr.aws.crossplane.io/v1beta1
kind: Repository
metadata:
  name: repo1-us-west-2
spec:
  forProvider:
    awsName: repo1
    region: us-west-2   
@brandocomando brandocomando added the enhancement New feature or request label Dec 14, 2023
@brandocomando brandocomando changed the title Support the ability to create the same resource in multiple regions Support the ability to create the same ECR Repository in multiple regions Dec 14, 2023
@bobh66
Copy link
Contributor

bobh66 commented Dec 14, 2023

You can do this using a Composition by patching the desired name into the crossplane.io/external-name annotation on the managed resource to specify the name used in AWS. The Repository objects would have unique names generated by the Composition, but the MRs can use the names you want in AWS.

@bobh66
Copy link
Contributor

bobh66 commented Dec 14, 2023

@brandocomando
Copy link
Author

Thank @bobh66 I didnt know we could already external-name annotation for this, very helpful for these kinds of regional resources.
I was already wrapping these repos in a helm chart so it made more sense to include the overwrite of the annotation in the helm chart rather than using compositions and or functions.

For the curious heres a snippet:

{{- $root := . -}}
{{- range $region := .Values.regions -}}
{{- range $repo := $root.Values.repositories }}
apiVersion: ecr.aws.crossplane.io/v1beta1
kind: Repository
metadata:
  name: {{ $repo.name }}-{{ $region }}
  annotations:
    crossplane.io/external-name: {{ $repo.name }}
spec:
  deletionPolicy: {{ $root.Values.deletionPolicy }}
  forProvider:
    region: {{ $region }}
  providerConfigRef:
    name: aws-provider-config
---
{{- end }}
{{- end }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants