AWS SQS Cross-Account Role Chaining Issue with KEDA Autoscaler #7457
Replies: 4 comments
-
|
Cross-account role chaining with KEDA's SQS scaler is supported. Here's how to set it up: ArchitectureStep 1: IAM Role A (your EKS account, Account 111)The KEDA operator's IAM role needs {
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::222222222222:role/keda-sqs-role"
}Step 2: Role B trust policy (target account, Account 222)Role B must trust the KEDA operator role (not the pod directly): {
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111111111111:role/keda-operator"
},
"Action": [
"sts:AssumeRole",
"sts:TagSession"
]
}Role B needs SQS read permissions: {
"Effect": "Allow",
"Action": [
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl"
],
"Resource": "arn:aws:sqs:*:222222222222:your-queue"
}Step 3: KEDA TriggerAuthenticationUse
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: sqs-cross-account-auth
spec:
podIdentity:
provider: aws
roleArn: "arn:aws:iam::222222222222:role/keda-sqs-role"
Step 4: ScaledObjectapiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: sqs-scaler
spec:
scaleTargetRef:
name: your-deployment
minReplicaCount: 0
maxReplicaCount: 100
pollingInterval: 30
cooldownPeriod: 300
triggers:
- type: aws-sqs-queue
metadata:
queueURL: https://sqs.us-east-1.amazonaws.com/222222222222/your-queue
awsRegion: us-east-1
queueLength: "5"
authenticationRef:
name: sqs-cross-account-authCommon causes of AccessDenied
DebuggingCheck KEDA operator logs for the specific error: kubectl logs -n keda deploy/keda-operator | grep -i "access\|error\|sqs"Can you share the specific AccessDenied error? That will pinpoint which leg of the chain is failing. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @nicknikolakakis — we followed the exact same setup you described. Our architecture is: Role A has However, it only works when we add Role A directly to the SQS queue resource policy in Account 222 — which bypasses the role chain entirely. Is this expected, or should the role chaining work without adding Role A to the queue policy? Without that queue policy, we get AccessDenied. This shouldn't be needed in a proper role chaining setup, right? Let me set it up again cleanly and share the KEDA operator logs here so we can pinpoint which leg of the chain is failing. |
Beta Was this translation helpful? Give feedback.
-
|
Ran into this today. The missing piece is in the above |
Beta Was this translation helpful? Give feedback.
-
|
Cross-account SQS + KEDA is a common pain point. The role chaining issue typically comes down to one of these: The trust relationship setup The KEDA operator needs to assume a role in Account A, and that role needs permission to assume a role in Account B. You need:
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-trigger-auth-aws-sqs
spec:
podIdentity:
provider: aws
awsSTSAuthentication:
roleArn: arn:aws:iam::<ACCOUNT_B>:role/keda-sqs-reader-roleCommon failure modes:
Debugging: enable KEDA operator verbose logging ( What's the specific error you're seeing in the KEDA operator logs? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We are implementing KEDA autoscaling based on AWS SQS queue metrics in EKS. Our setup involves cross-account access where the pod IAM role needs to assume another role in a different AWS account to read SQS metrics.
Direct access to the target role is not allowed in our governance model, so we must use IAM role chaining. We tried setting up role chaining, but it’s currently failing with AccessDenied errors.
Has anyone successfully configured KEDA with cross-account role chaining for SQS autoscaling? Any guidance or recommended approach would really help.
Beta Was this translation helpful? Give feedback.
All reactions