Twingate / kubernetes-operator

Twingate Kubernetes Operator allows configuring Twingate using Kubernetes assets - OSS
https://www.twingate.com
Mozilla Public License 2.0
19 stars 1 forks source link

It's not clear in the API reference how to add access to more than one group in TwingateResourceAccess #300

Open AlexisDaciuk opened 1 month ago

AlexisDaciuk commented 1 month ago

What is missing?

Examples of real life use cases of various Twingate resources

Why do we need it?

So no one needs to open a Github issue asking for syntax help

Environment

Anything else we need to know?:

After finding the needed syntax in Issue 32 I was able to add one group to the TwingateResource but not able to add more than one group

What work is

apiVersion: twingate.com/v1beta
kind: TwingateResourceAccess
metadata:
  name: test-access
spec:
  resourceRef:
    name: test
    namespace: dev
  principalExternalRef:
    type: group
    name: DevOps Team

I tried (and doesn't work)

  principalExternalRef:
    type: group
    name: 
      - DevOps Team
      - Founders
  principalExternalRef:
    - type: group
      name: DevOps Team
    - type: group
      name: Founders

and even

  principalExternalRef:
    - type: group
      name: "DevOps Team, Founders"

Is there a way to assign more than one group using TwingateResourceAccess?

Thanks Alex

linear[bot] commented 1 month ago

OSS-37 It's not clear in the API reference how to add access to more than one group in TwingateResourceAccess

ekampf commented 1 month ago

Hey @AlexisDaciuk , Giving multiple principals access to a resource requires multiple TwingateResourceAccess objects. Each object represents a single edge betweena resource and a principal.

ekampf commented 1 month ago

Turning principalExternalRef into plural principalExternalRefs is an interesting idea though... Will keep this issue open as a feature request for that

AlexisDaciuk commented 1 month ago

Thanks for the clarification

I am looking into automating the deploy of Twingate Resources using Helm and ArgoCD and looking for a easy way to give access to multiple groups

Turning it into principalExternalRefs should make it easier from the Helm side of things

AlexisDaciuk commented 1 month ago

Maybe will help somebody, I was able to make it work with helm

With .Values.twingate.groups being a String list

{{- range $name := .Values.twingate.groups }}
---
apiVersion: twingate.com/v1beta
kind: TwingateResourceAccess
metadata:
  name: {{ $.Values.metadata.name }}-{{ $name | lower | nospace }}
  namespace: {{ $.Values.metadata.namespace }}
spec:
  resourceRef:
    name: {{ $.Values.metadata.name }}
    namespace: {{ $.Values.metadata.namespace }}
  principalExternalRef:
    type: group
    name: {{ $name }}  
{{- end }}