Securing scaler access to event sources: secretTargetRef, env, and podIdentity patterns for AWS, Azure, and GCP, plus the difference between TriggerAuthentication and ClusterTriggerAuthentication.

After episodes 4 and 5, you can create working ScaledObjects and ScaledJobs. But there's one practical hurdle waiting the moment a scaler touches a real system: authentication. A protected SQS queue, Kafka, or Prometheus won't hand over data just because you ask for it.
Episode 6 covers TriggerAuthentication and ClusterTriggerAuthentication: objects that store how KEDA proves its identity to event sources, complete with the most common credential patterns in the field.
Credentials are highly sensitive data. You don't want to write them inside a ScaledObject — an object managed by many people and often committed to Git. KEDA separates the two: the ScaledObject holds "what to read", the TriggerAuthentication holds "with what credentials to read it".
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: sqs-worker-scaledobject
spec:
scaleTargetRef:
name: sqs-worker
minReplicaCount: 0
maxReplicaCount: 10
triggers:
- type: aws-sqs-queue
authenticationRef:
name: keda-trigger-auth-sqs
metadata:
queueURL: https://sqs.ap-southeast-1.amazonaws.com/1234/orders
queueLength: "5"Credentials are defined separately, replaced by a reference to the authentication object's name. Credential rotation never touches the ScaledObject at all. To see how this authentication object is referenced from KEDA's side, run kubectl get triggerauthentication -n your-namespace and read its spec field.
KEDA provides three main patterns. Choose based on your infrastructure and the level of security you need.
The simplest pattern: credentials are stored in a Kubernetes Secret, then read by KEDA and passed as scaler parameters.
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-sqs
spec:
secretTargetRef:
- parameter: awsAccessKeyID
name: aws-secrets
key: AWS_ACCESS_KEY_ID
- parameter: awsSecretAccessKey
name: aws-secrets
key: AWS_SECRET_ACCESS_KEYThe parameter field connects a value to the parameter the scaler expects, while name and key point at the Secret. Make sure the Secret is in the same namespace — this pattern can't cross namespaces.
Warning
The secretTargetRef pattern is a convenience that also carries responsibility. Encrypt Secrets in the cluster, restrict RBAC access, and avoid putting raw Secrets in Git. For large teams, consider the Vault integration at the end of this episode.
The env pattern takes credentials from the KEDA pod's environment variables — useful when credentials are injected by an external mechanism, such as an init container or admission controller:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-prometheus
spec:
env:
- name: PROMETHEUS_TOKEN
parameter: bearerTokenThe PROMETHEUS_TOKEN value is read from the keda-operator environment at runtime, not from a YAML file — credentials never appear in Git.
The safest and most modern pattern: no static credentials at all. KEDA uses the cloud workload identity already attached to the operator pod — an IAM role on AWS, a managed identity on Azure, or a service account on GCP.
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-aws
spec:
podIdentity:
provider: aws
identityId: arn:aws:iam::123456789012:role/keda-sqs-readerAvailable providers: aws (IRSA/EKS), azure (Azure workload identity for AKS), and gcp (GCP IAM Workload Identity). The key to this pattern: the KEDA operator is annotated with an identity that has minimal permissions — for example, only sqs:GetQueueAttributes to read queue length. No rotating secrets, no credential leaks.
kubectl describe scaledobject sqs-worker-scaledobject
kubectl get triggerauthentication
kubectl logs -n keda deploy/keda-operator | tail -20The difference between the two is as simple as scope:
| Aspect | TriggerAuthentication | ClusterTriggerAuthentication |
|---|---|---|
| Scope | One namespace | Entire cluster |
| Referenced with | authenticationRef.name | clusterTriggerAuthenticationRef.name |
| Use case | Teams hold their own credentials | Shared platform, centralized credentials |
With ClusterTriggerAuthentication, a platform team can provide credentials to the company queue once, and then all teams in all namespaces use it — without each team storing its own secret:
spec:
triggers:
- type: aws-sqs-queue
clusterTriggerAuthenticationRef:
name: keda-platform-sqs
metadata:
queueURL: https://sqs.ap-southeast-1.amazonaws.com/1234/orders
queueLength: "5"Tip
Because ClusterTriggerAuthentication is used across namespaces, restrict who can create it via a ClusterRole in RBAC — this object is effectively the "master key" to every event source in the cluster.
For organizations already using HashiCorp Vault or external operators (External Secrets Operator, Sealed Secrets), the favorite pattern is populating Kubernetes Secrets from Vault, then using the secretTargetRef pattern. KEDA doesn't need to know Vault exists:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-kafka
spec:
secretTargetRef:
- parameter: sasl
name: kafka-secret
key: saslCredential rotation is handled by the External Secrets Operator in one place, and the TriggerAuthentication stays stable. This pattern combines Vault security with the simplicity of secretTargetRef.
Episode 6 closes the access security foundation. Here's what you must bring along:
secretTargetRef, env, and podIdentity (safest in the cloud).podIdentity supports IRSA/EKS, Azure workload identity, and GCP IAM.In episode 7 we'll get to know the scalers most often used for everyday workloads: CPU/memory and cron for schedule prediction, then Prometheus and HTTP for custom metrics and pending requests.