Skip to content

Add S3-specific endpoint to generated AWS profile - #473

Merged
anisaoshafi merged 1 commit into
mainfrom
support-s3-to-aws-profile
Oct 19, 2026
Merged

anisaoshafi merged 1 commit into
mainfrom
support-s3-to-aws-profile

Conversation

@anisaoshafi

@anisaoshafi anisaoshafi commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

aws --profile localstack used directly (not through lstk's own proxies) sent S3 requests to the profile's general endpoint, breaking S3's virtual-host-style bucket addressing.

Solution

lstk setup aws now writes an S3 endpoint override in a [services localstack] block, referenced via services = localstack in the profile. It reuses the existing endpoint.S3Addressing helper already used by the Terraform/CDK proxies. This block follows the same idempotency and --force overwrite rules as the rest of the profile.

Review

Small, self-contained, covered by unit and integration tests. Self-merge candidate.

Closes DEVX-755

@anisaoshafi anisaoshafi added semver: patch docs: skip Pull request does not require documentation changes labels Aug 27, 2026
@anisaoshafi
anisaoshafi force-pushed the support-s3-to-aws-profile branch 3 times, most recently from a55a980 to 295b8ed Compare August 31, 2026 14:42
@anisaoshafi
anisaoshafi force-pushed the support-s3-to-aws-profile branch 4 times, most recently from 3f4efd8 to d9e5d98 Compare September 5, 2026 13:41
@anisaoshafi
anisaoshafi marked this pull request as ready for review September 5, 2026 16:23
@anisaoshafi
anisaoshafi requested review from a team and peter-smith-phd as code owners September 5, 2026 16:23
@anisaoshafi
anisaoshafi enabled auto-merge (squash) September 5, 2026 16:24

@joe4dev joe4dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good to see S3 compatibility addressed in the AWS profile. That's particularly important to cdk. I really like the non-destructive edit in ~/.aws/profile 👏 ✨

A couple of non-blocking questions/suggestions:

❓ Do we want to offer a fallback for customers being blocked by DNS rebind protection, similar to the probing we do in the LocalStack Toolkit https://github.com/localstack/localstack-toolkit-vscode/pull/51?

This block follows the same idempotency and --force overwrite rules as the rest of the profile.

❓ What is the intended behavior of --force?
Given an existing ~/.aws/profile, both non-force and --force performed a non-destructive edit. Does --force simply skip the interactive "[Y/n]" prompt?

nit: The confirmation message "✔︎ Created LocalStack profile in ~/.aws/config" does not distinguish between Create and Update.

Sidenotes

Not directly related, just FYI:

  • The lstk aws proxy command does not respect the --profile localstack. Is this intentional or is there a workaround?
  • The AWS VSCode Extension cannot parse the service-specific section and spams verbose logs (their bug):
    Image

@anisaoshafi
anisaoshafi force-pushed the support-s3-to-aws-profile branch from d9e5d98 to c14d0a2 Compare October 19, 2026 11:25
@anisaoshafi
anisaoshafi merged commit c51cdc4 into main Oct 19, 2026
17 checks passed
@anisaoshafi
anisaoshafi deleted the support-s3-to-aws-profile branch October 19, 2026 11:25
@anisaoshafi

Copy link
Copy Markdown
Collaborator Author

Thanks for your feedback @joe4dev!

Do we want to offer a fallback for customers being blocked by DNS rebind protection, similar to the probing we do in the LocalStack Toolkit localstack/localstack-toolkit-vscode#51?

We already have this, and the PR keeps it working. lstk setup aws calls endpoint.ResolveHost, which looks up test.localhost.localstack.cloud. If that fails or doesn't return 127.0.0.1, it uses 127.0.0.1: and prints a note.

What is the intended behavior of --force?

In the interactive flow, --force just skips the [Y/n] prompt. In non-interactive mode (CI for example), lstk won't change an existing localstack profile that has different values unless you pass --force

nit: The confirmation message "✔︎ Created LocalStack profile in ~/.aws/config" does not distinguish between Create and Update.

This wording has been like this since the profile setup flow was added, and it applies to every profile write. I left it as is to keep this PR focused, I image the reason why it didn't distinguish originally was to not complicate logic. Happy to change in a follow up if you think it's important.

The lstk aws proxy command does not respect the --profile localstack. Is this intentional or is there a workaround?

lstk aws uses the localstack profile when it exists. But it doesn't use the profile's endpoints, because lstk adds its own --endpoint-url with the emulator address it found, and the aws cli gives that flag priority over the profile.

If you want the profile's endpoints, either pass your own --endpoint-url after the command, for example lstk aws s3 ls --endpoint-url http://.... or run aws --profile localstack ... directly, without lstk.❓ Did you run into a problem because of this?

joe4dev commented Oct 19, 2026

Copy link
Copy Markdown
Member

lstk aws uses the localstack profile when it exists. But it doesn't use the profile's endpoints, because lstk adds its own --endpoint-url with the emulator address it found

I found that counter-intuitive if I want to test certain networking scenarios through my global AWS profile.

Did you run into a problem because of this?

I often have to use the AWS CLI directly because lstk does not let me connect to a running dev / host mode instance. I would expect lstk aws to succeed if finds the health endpoint of a LocalStack instance running at the endpoint configured in the profile rather than over-relying on the lstk -managed Docker instance.

@joe4dev

joe4dev commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Did you run into a problem because of this?

The main blocker is the LocalStack Toolkit for VS Code in dev mode: I cannot open App Inspector during development because it depends on lstk detecting a running instance. This works with other tools such as the LS Console (i.e., Web App).

Do we have an issue for this?

@anisaoshafi

Copy link
Copy Markdown
Collaborator Author

Did you run into a problem because of this?

The main blocker is the LocalStack Toolkit for VS Code in dev mode: I cannot open App Inspector during development because it depends on lstk detecting a running instance. This works with other tools such as the LS Console (i.e., Web App).

Do we have an issue for this?

I created this issue https://linear.app/localstack/issue/DEVX-1223 and will take a look one of these days. Thanks for raising this issue.

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

Labels

docs: skip Pull request does not require documentation changes semver: patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants