apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: tf-controller-clusterrole
rules:
  - apiGroups:
      - ""
    resources:
      - "configmaps"
    verbs:
      - "list"
      - "watch"
      - "get"
      - "create"
      - "update"
      - "watch"
      - "delete"

  # Required to write terraform outputs
  - apiGroups:
      - ""
    resources:
      - "secrets"
      - "serviceaccounts"
    verbs:
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "watch"
      - "delete"

  - apiGroups:
      - "batch"
    resources:
      - "jobs"
    verbs:
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "watch"

  - apiGroups:
      - ""
    resources:
      - "pods/log"
      - "pods"
    verbs:
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "watch"
      - "delete"

  - apiGroups:
      - "terraform.core.oam.dev"
    resources:
      - "configurations"
      - "providers"
      - "providers/status"
      - "configurations/status"
    verbs:
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "watch"

  - apiGroups:
      - "rbac.authorization.k8s.io"
    resources:
      - "clusterroles"
      - "clusterrolebindings"
    verbs:
      - "get"
      - "list"
      - "create"
      - "update"
      - "delete"
      - "watch"

  - apiGroups:
      - "coordination.k8s.io"
    resources:
      - "leases"
    verbs:
      - "get"
      - "create"
      - "update"
      - "delete"
