Skip to content

feat(webhook): support multi-region SQS dispatch in runner webhook - #5099

Merged
edersonbrilhante merged 3 commits into
github-aws-runners:mainfrom
bogdankrasko:pr/bk/update-dispatch-runner-lambda-sqs-multi-region
Jul 13, 2026
Merged

edersonbrilhante merged 3 commits into
github-aws-runners:mainfrom
bogdankrasko:pr/bk/update-dispatch-runner-lambda-sqs-multi-region

Conversation

@bogdankrasko

@bogdankrasko bogdankrasko commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR updates the webhook SQS dispatch logic to select the SQS client region from the target queue URL instead of always using AWS_REGION.

This fixes cross-region dispatch scenarios where the webhook needs to send workflow job messages to an SQS queue in a different AWS region than the Lambda runtime. The change also caches SQS clients per region so repeated sends reuse the correct client while still creating separate clients when queues are in different regions.

To support this model, the webhook runner_matcher_config must include each runner group's matcherConfig together with the region-specific SQS queue URL (id) and queue ARN (arn) for every runner group in every region. This allows the webhook to match the job and dispatch it to the correct regional queue.

This also requires runner pool labels to be unique across all configured regions so webhook matching remains deterministic and a given job maps to exactly one regional queue.

Test Plan

  • Added and updated unit tests in lambdas/functions/webhook/src/sqs/index.test.ts to cover:
    • queue URL region parsing
    • fallback to AWS_REGION when the queue URL cannot be parsed
    • behavior when no region can be resolved
    • client reuse for multiple queues in the same region
    • separate clients for different queue regions
  • Ran yarn vitest run functions/webhook/src/sqs/index.test.ts
  • Deployed the webhook stack only in the primary region, us-east-2, so a single API Gateway/webhook entrypoint handles workflow dispatch for runner queues across multiple AWS regions
  • Deployed validation stacks across multiple AWS regions using modules/runners. This setup provisions per-runner-group Lambda functions (scale-up, scale-down, pool, and job-retry), along with the SQS queues defined in modules/multi-runner/queues.tf. This was used to validate both same-region and cross-region dispatch behavior.
    To enable it, an additional wrapper was introduced within modules/runners to incorporate the required SQS queues.
    • us-east-2: Ubuntu 24.04 runner pools for both amd64 and arm64. This region was used to validate that jobs with architecture-specific labels were matched correctly and dispatched successfully to queues in the local region.
    • us-west-2: Ubuntu 24.04 amd64-2 runner pool. This region was used as the secondary-region target to validate that the webhook could dispatch a workflow job to an SQS queue outside the Lambda runtime region.
  • Triggered workflow job dispatch in the deployed environment and verified that the webhook sent messages successfully to the expected queue in each case, including the cross-region queue path this change is intended to support

Related Issues

@edersonbrilhante edersonbrilhante left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdankrasko Can you please sign the commits?

Derive the SQS client region from the queue URL instead of always using AWS_REGION. This prevents cross-region SignatureDoesNotMatch failures when the webhook sends messages to queues outside the Lambda region.

Cache traced SQS clients by region to avoid recreating clients for repeated sends, while still creating separate clients for different queue regions. Fall back to AWS_REGION when the queue URL cannot be parsed, and fall back to the SDK default region resolution when no region is available.

Expand unit coverage for queue URL region parsing, AWS_REGION fallback, missing-region behavior, same-region client reuse, and per-region client separation.
@bogdankrasko
bogdankrasko force-pushed the pr/bk/update-dispatch-runner-lambda-sqs-multi-region branch from c21be98 to 204dbcd Compare July 8, 2026 14:50
@bogdankrasko

Copy link
Copy Markdown
Contributor Author

@edersonbrilhante Sure, signed the commits. Let me know if you have any questions regarding the changes.

@bogdankrasko

Copy link
Copy Markdown
Contributor Author

@edersonbrilhante Fixed the linter issues

@edersonbrilhante
edersonbrilhante merged commit 768d08b into github-aws-runners:main Jul 13, 2026
8 checks passed
edersonbrilhante added a commit that referenced this pull request Jul 13, 2026
## Description

Handle webhook events whose installationId belongs to a different GitHub
App by retrying installation authentication after a 404.

Apply the fallback in both the shared Octokit helper and the scale-up
flow by re-resolving the installation ID for the current app before
retrying auth.

Preserve existing behavior for installationId=0 and non-404 errors, and
add regression tests covering the mismatched installation/app scenario.

## Test Plan

Follow the instructions in
#5099
to deploy runners to multiple regions, and set the GitHub App secrets in
SSM so that each region has its own GitHub App ID.

## Related Issues

<!-- Link any related issues, e.g. Fixes #123, Closes #456 -->

---------

Co-authored-by: Ederson Brilhante <[email protected]>
edersonbrilhante pushed a commit that referenced this pull request Jul 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[7.10.0](v7.9.0...v7.10.0)
(2026-07-17)


### Features

* **pool:** Allow to optionally include busy runners into the pool
([#5078](#5078))
([c3eeb0f](c3eeb0f))
* **runners:** support OnDemandOptions.AllocationStrategy in EC2 Fleet
([#5077](#5077))
([28b90f4](28b90f4))
* **termination-watcher:** deregister runners from GitHub on EC2
termination
([#5055](#5055))
([c7494c1](c7494c1))
* **webhook:** support multi-region SQS dispatch in runner webhook
([#5099](#5099))
([768d08b](768d08b))


### Bug Fixes

* **deps:** bump actions/stale from 10.3.0 to 10.4.0 in the github group
([#5210](#5210))
([ef8719e](ef8719e))
* **deps:** bump github/codeql-action/upload-sarif from 4.36.2 to 4.36.3
([#5207](#5207))
([c7a8096](c7a8096))
* retry installation auth for regional GitHub App events
([#5123](#5123))
([8222052](8222052))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: runners-releaser[bot] <194412594+runners-releaser[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants