Skip to content

fix: failing to get correct region when it is configured with variables#736

Merged
sid88in merged 1 commit into
sid88in:masterfrom
gjhommersom:fix/unable-to-load
Jul 8, 2026
Merged

fix: failing to get correct region when it is configured with variables#736
sid88in merged 1 commit into
sid88in:masterfrom
gjhommersom:fix/unable-to-load

Conversation

@gjhommersom

@gjhommersom gjhommersom commented Jul 2, 2026

Copy link
Copy Markdown

Proposed changes

Defer loading of the region until Serverless has resolved the configuration.
https://www.serverless.com/framework/docs/guides/plugins/creating-plugins#serverless-instance

Issue(s)

This fixes an issue introduced in version 2.11 that stops the region configuration from being loaded properly.

Steps to test or reproduce

Trying to run serverless deploy with a configuration like below will fail because the region is invalid.

provider:
  name: aws
  region: ${opt:region, param:provider_region}
params:
  default:
    provider_region: eu-west-1

  prod:
    provider_region: eu-central-1

Summary by CodeRabbit

  • Bug Fixes
    • Improved plugin startup behavior by delaying cloud configuration lookup until it is actually needed.
    • Reduced the chance of initialization issues when region or credentials are not immediately available.
    • This should make deploy and command execution more reliable in environments with deferred AWS setup.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f5efe2f-388f-4f68-b4ca-f870cdfddc72

📥 Commits

Reviewing files that changed from the base of the PR and between ddb9896 and 903b712.

📒 Files selected for processing (1)
  • src/index.ts

📝 Walkthrough

Walkthrough

The ServerlessAppsyncPlugin constructor no longer eagerly resolves AWS region and credentials to build AwsClientFactory. Instead, an optional backing field is stored, and a private getter lazily initializes and caches the factory on first access.

Changes

Lazy client factory initialization

Layer / File(s) Summary
Deferred AwsClientFactory construction
src/index.ts
Constructor no longer eagerly resolves region/credentials or constructs AwsClientFactory; a private clientFactory getter now lazily resolves and caches it on first access.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: AlexHladin

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: delaying region resolution when the region is configured via variables.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sid88in sid88in self-requested a review July 8, 2026 02:02

@sid88in sid88in left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

lgtm. thanks for the fix!

@sid88in sid88in merged commit 6c31a16 into sid88in:master Jul 8, 2026
6 checks passed
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