{{ if .Values.rbac.create }}
apiVersion: {{ template "rbac.apiVersion" . }}
kind: ClusterRoleBinding
metadata:
  name: {{ template "prometheus-cloudwatch-exporter.fullname" . }}
  labels:
    app: {{ template "prometheus-cloudwatch-exporter.name" . }}
    chart: {{ template "prometheus-cloudwatch-exporter.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
subjects:
  - kind: ServiceAccount
    name: {{ template "prometheus-cloudwatch-exporter.serviceAccountName" . }}
    namespace: {{ .Release.Namespace }}
roleRef:
  kind: ClusterRole
  name: {{ template "prometheus-cloudwatch-exporter.fullname" . }}
  apiGroup: rbac.authorization.k8s.io
{{ end }}
