Skip to content

fix: Error while deploying to localstack or MinIo resolved as S3 was always pointing to the default aws environment and failing to save artifacts metadata#13586

Open
naieem wants to merge 1 commit into
serverless:mainfrom
naieem:feature/localstack-s3-deploy
Open

fix: Error while deploying to localstack or MinIo resolved as S3 was always pointing to the default aws environment and failing to save artifacts metadata#13586
naieem wants to merge 1 commit into
serverless:mainfrom
naieem:feature/localstack-s3-deploy

Conversation

@naieem
Copy link
Copy Markdown

@naieem naieem commented May 15, 2026

feat(s3): support custom endpoint via AWS_ENDPOINT_URL env var

Summary

Adds support for local/custom S3-compatible endpoints (e.g. LocalStack, MinIO) by
reading the AWS_ENDPOINT_URL environment variable at client initialization time.

Problem

The AwsS3Client constructor had no way to target a non-AWS S3-compatible endpoint.
This made local development and integration testing difficult — developers had to either
work against real AWS buckets or monkey-patch the client after instantiation.

Solution

Before constructing the S3Client, the constructor now checks for AWS_ENDPOINT_URL.
If present, it merges two additional options into awsConfig:

  • endpoint — points the client at the custom URL
  • forcePathStyle: true — required by most S3-compatible services (LocalStack, MinIO,
    etc.) which do not support virtual-hosted-style bucket addressing
// Before
constructor(awsConfig = {}) {
  this.client = addProxyToAwsClient(
    new S3Client({ ...awsConfig, followRegionRedirects: true }),
  )
}

// After
constructor(awsConfig = {}) {
  if (process.env.AWS_ENDPOINT_URL) {
    awsConfig = {
      ...awsConfig,
      forcePathStyle: true,
      endpoint: process.env.AWS_ENDPOINT_URL,
    }
  }
  this.client = addProxyToAwsClient(
    new S3Client({ ...awsConfig, followRegionRedirects: true }),
  )
}

Why this approach

  • Zero breaking changes — the env var is optional; existing behavior is fully
    preserved when it is unset.
  • Convention over configurationAWS_ENDPOINT_URL is the de-facto standard
    variable used by the AWS CLI, LocalStack, and many CI setups, so no extra
    documentation is needed.
  • Minimal surface area — the change is self-contained in the constructor; no new
    parameters, no new public methods.

Testing

Set AWS_ENDPOINT_URL=http://localhost:4566 (or your local stack URL) and run the
existing S3 integration tests — all bucket operations should route to the local
endpoint without any code changes.

Checklist

  • No breaking changes
  • Works with existing awsConfig overrides
  • Compatible with LocalStack and MinIO
  • No new dependencies

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for custom S3 endpoint configuration via environment variable, enabling path-style addressing for S3-compatible storage services. This allows seamless integration with alternative endpoint providers without requiring code modifications.

Review Change Stack

@Mmarzex
Copy link
Copy Markdown
Contributor

Mmarzex commented May 15, 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
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

AwsS3Client constructor now detects the AWS_ENDPOINT_URL environment variable. When present, it augments the AWS SDK configuration to enable path-style addressing and sets the custom endpoint URL before creating the S3 client, allowing integration with S3-compatible storage services.

Changes

Custom S3 Endpoint Configuration

Layer / File(s) Summary
Custom S3 endpoint conditional configuration
packages/engine/src/lib/aws/s3.js
Constructor checks for AWS_ENDPOINT_URL environment variable and, when set, merges forcePathStyle: true and endpoint config into awsConfig before instantiating S3Client.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A little toggle, oh what delight,
AWS endpoints now burning bright,
Path-style paths and custom URLs flow,
S3-compatible magic starts to glow! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The title accurately describes the main change: adding support for custom S3 endpoints (LocalStack/MinIO) by reading AWS_ENDPOINT_URL environment variable, which resolves deployment errors when using non-default S3-compatible services.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@naieem naieem changed the title fix: deploying error resolved when using localstack or MinIO as s3 was always pointing to the default aws environment fix: Error while deploying to localstack or MinIo resolved as S3 was always pointing to the default aws environment and failing to save artifacts metadata May 15, 2026
@naieem
Copy link
Copy Markdown
Author

naieem commented May 15, 2026

I have read the CLA Document and I hereby sign the CLA

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