Skip to content

feat(aws): add support for externalId in AssumeRole for TriggerAuthentication#7580

Open
zeevimeytar wants to merge 1 commit intokedacore:mainfrom
zeevimeytar:nrnd-2801-add-support-for-externalid-in-assumerole-for
Open

feat(aws): add support for externalId in AssumeRole for TriggerAuthentication#7580
zeevimeytar wants to merge 1 commit intokedacore:mainfrom
zeevimeytar:nrnd-2801-add-support-for-externalid-in-assumerole-for

Conversation

@zeevimeytar
Copy link
Copy Markdown

@zeevimeytar zeevimeytar commented Apr 1, 2026

This PR adds support for passing an externalId when KEDA assumes an AWS IAM role via the TriggerAuthentication resource. The external ID is a security best practice for cross-account role assumption that prevents the "confused deputy" problem.

The externalId is specified as a field in spec.podIdentity, consistent with how roleArn is already modeled on AuthPodIdentity:

apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: aws-trigger-auth
spec:
  podIdentity:
    provider: aws
    roleArn: "arn:aws:iam::123456789012:role/your-cross-account-role"
    externalId: "your-external-id-here"

The external ID is passed to AWS STS during the AssumeRole API call, which is required when assuming roles that have an sts:ExternalId condition in their trust policy.

Note: This PR supersedes #7388, which implemented the same feature using a metadata annotation (keda.sh/aws-role-external-id). Both PR authors are from the same organization. Based on the review feedback in #7388 — specifically @JorTurFer's request to use a spec field instead of an annotation for better alignment with existing configurations — this PR reimplements the feature as a first-class spec field. PR #7388 will not be continued and can be closed in favour of this one.

Changes

  • Add ExternalID *string field (json:"externalId,omitempty") to AuthPodIdentity spec
  • Add AwsRoleExternalID field to AuthorizationMetadata
  • Map podIdentity.ExternalID to authParams["awsRoleExternalId"] in ResolveAuthRefAndPodIdentity
  • Parse awsRoleExternalId from authParams in GetAwsAuthorization
  • Include ExternalID in cache key generation to ensure separate cache entries per external ID
  • Pass ExternalID to AssumeRoleOptions in retrievePodIdentityCredentials (pod identity path)
  • Pass ExternalID to AssumeRoleOptions in GetAwsConfig (deprecated aws-eks path)
  • Regenerate CRD manifests and deepcopy code
  • Add unit tests for external ID parsing and cache key differentiation

Checklist

  • When introducing a new scaler, I agree with the scaling governance policy
  • I have verified that my change is according to the deprecations & breaking changes policy
  • Tests have been added (if applicable)
  • Ensure make generate-scalers-schema has been run to update any outdated generated files
  • Changelog has been updated and is aligned with our changelog requirements, only when the change impacts end users
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

Fixes #

Relates to #7388

@zeevimeytar zeevimeytar requested a review from a team as a code owner April 1, 2026 10:41
@snyk-io
Copy link
Copy Markdown

snyk-io Bot commented Apr 1, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 1, 2026

Thank you for your contribution! 🙏

Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected.

While you are waiting, make sure to:

  • Add an entry in our changelog in alphabetical order and link related issue
  • Update the documentation, if needed
  • Add unit & e2e tests for your changes
  • GitHub checks are passing
  • Is the DCO check failing? Here is how you can fix DCO issues

Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient.

Learn more about our contribution guide.

@keda-automation keda-automation requested a review from a team April 1, 2026 10:41
@zeevimeytar zeevimeytar force-pushed the nrnd-2801-add-support-for-externalid-in-assumerole-for branch from 36942ff to 1726856 Compare April 1, 2026 10:50
@zeevimeytar
Copy link
Copy Markdown
Author

Hey @JorTurFer, would appreciate your review here 😄

@zeevimeytar zeevimeytar force-pushed the nrnd-2801-add-support-for-externalid-in-assumerole-for branch from 1726856 to 4b9122e Compare April 10, 2026 16:17
@zeevimeytar
Copy link
Copy Markdown
Author

Happy to make changes here if required, @rickbrouwer 😃

…uthentication

Signed-off-by: Meytar Zeevi <Meytar@rocksteady.io>
@zeevimeytar zeevimeytar force-pushed the nrnd-2801-add-support-for-externalid-in-assumerole-for branch from 4b9122e to 6a73e0b Compare April 19, 2026 06:51
@rickbrouwer rickbrouwer added the related-pr This is a PR that is related to another PR. The potential merging may affect the related PR. label Apr 20, 2026
@rickbrouwer
Copy link
Copy Markdown
Member

rickbrouwer commented Apr 22, 2026

Related with #6916 and #7665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

related-pr This is a PR that is related to another PR. The potential merging may affect the related PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants