Force S3 path style for lstk cdk on CDK 2.1138.0+ - #497
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
peter-smith-phd
marked this pull request as ready for review
September 9, 2026 02:05
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Now that CDK (version 2.1138.0 and higher) supports the
CDK_S3_FORCE_PATH_STYLEflag, we can now do better at enabling S3 path-style access whenever necessary, such as for LocalStack endpoints that don't naturally support virtual host names, such ashttp://localhost:4566. In fact, our own ephemeral instances don't support<bucket>.s3.as a prefix on the DNS name, so virtual-host-style access had previously resulted in an error.Solution
For CDK 2.1138.0 and higher, set
CDK_S3_FORCE_PATH_STYLE=1for thecdksubprocess and pass the S3 endpoint through unprefixed (that is, without thes3.prefix). For older CDK versions, there's no impact, and thes3.prefix is still required in order to trigger virtual-host-style resolution.Testing
Validated with:
http://localhost:4566http://127.0.0.1:4566http://127-0-0-1.sslip.io:4566- resolves to 127.0.0.1, but not a pattern thatlstkpreviously looked for.https://ls-xxxxxx.sandbox.localstack.cloudCloses DPX-723