Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@
### Breaking changes

- **Service-URL mode moves from `useServiceUrl` to configuration.** The `bool useServiceUrl` overloads are removed from `Session`, from the eight Extensions registration methods, and from `ISession` except for the hidden, obsolete generic `CreateClientByInterface<TClient>(bool)` overload. That one overload keeps published Extensions 3.0.x binaries working with Core 3.1; the other removals still break binaries that call them. Source calls that pass the bool to the retained overload get CS0618; calls to the removed overloads must change before recompiling. Use `LocalStack:Config:UseServiceUrl` (`bool`, default `false`), bound into `ConfigOptions.UseServiceUrl`, to enable service-URL mode for every client of the session or service collection. Visual Basic callers whose `AddAwsService` call now resolves to the AWS SDK's `AddAWSService` (VB names are case-insensitive) should call `AddAWSServiceLocalStack`. A custom `ISession` implementation must implement the four 3.1 creation members without `useServiceUrl` (generic and `Type`, by implementation and by interface) and must keep implementing the generic `CreateClientByInterface<TClient>(bool)` overload until 4.0.0.
- **Legacy per-service ports are removed.** Every configured LocalStack endpoint uses `EdgePort`. Removed `IConfigOptions.UseLegacyPorts`, `ConfigOptions.UseLegacyPorts`, `AwsServiceEndpointMetadata.Port` and `ByPort(int)`, and `GetAwsServicePorts()` and `GetAwsServicePort(AwsService)` from both `IConfig` and `Config`. The `ConfigOptions(string, bool, bool, int)` constructor is replaced by `ConfigOptions(string, bool, int, bool useServiceUrl)`; the parameterless constructor stays. This breaks 3.0-compiled callers of the removed constructor and members. Migrate and recompile. The removed `Constants.UseLegacyPorts` constant breaks recompilation, not already-compiled reads, which inlined `false`. A leftover `LocalStack:Config:UseLegacyPorts` key is ignored for any value, including `yes`.

### Deprecated

- `ISession.CreateClientByInterface<TClient>(bool)` is hidden and obsolete. It remains only to let published Extensions 3.0.x binaries run on Core 3.1 and will be removed in 4.0.0. Use `LocalStack:Config:UseServiceUrl` instead.

### Migrating from 3.0

- `useServiceUrl: true` on a registration or `Session` call: set `LocalStack:Config:UseServiceUrl` to `true` instead, or pass `new ConfigOptions(localStackHost, useSsl, useLegacyPorts, edgePort, useServiceUrl: true)` to `SessionStandalone`. The setting covers every client of that session.
- `useServiceUrl: true` on a registration or `Session` call: set `LocalStack:Config:UseServiceUrl` to `true` instead, or pass `new ConfigOptions(localStackHost, useSsl, edgePort, useServiceUrl: true)` to `SessionStandalone`. The setting covers every client of that session.
- The third positional `ConfigOptions` argument is now `edgePort`. Remove the old third argument, or pass the port as `edgePort:`. A literal `true` or `false` in that position no longer compiles, but `new ConfigOptions("h", false, default)` still compiles and now sets the port to `0` instead of using `4566`.
- IoT Data Plane, IoT Jobs Data Plane and MediaStore Data clients need nothing any more: they get their service URL automatically.
- A presigned S3 URL that should name LocalStack: use `UseServiceUrl: true`, `UseSsl: true` with a TLS listener, or an AWS-standard endpoint such as `AWS_ENDPOINT_URL_S3`.

### Behavior changes

These apply to clients built with `UseLocalStack: true`; with `UseLocalStack: false` the AWS factory behavior is unchanged. The rule is documented in the README's [endpoint precedence](README.md#endpoint-precedence) section and in [ADR 0005](docs/adr/0005-endpoint-precedence-and-signing-region.md), and it fixes [#27](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/27) and, for explicit endpoints, [#50](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/50).
Items 1–11 apply to clients built with `UseLocalStack: true`; with `UseLocalStack: false` the AWS factory behavior is unchanged. Item 12 is a direct metadata call that does not consult `UseLocalStack`, so it applies in either mode. The rule is documented in the README's [endpoint precedence](README.md#endpoint-precedence) section and in [ADR 0005](docs/adr/0005-endpoint-precedence-and-signing-region.md), and it fixes [#27](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/27) and, for explicit endpoints, [#50](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/50).

1. **An AWS-standard endpoint now wins**, so traffic goes where the AWS SDK says. When the SDK resolves `AWS_ENDPOINT_URL_<SERVICE>`, `AWS_ENDPOINT_URL` or a profile `endpoint_url` for a client, that client uses it and no proxy. Previously the proxy still sent the request to the configured LocalStack endpoint while the request named the other endpoint. The decision is per client: `AWS_ENDPOINT_URL_S3` alone moves only S3 clients.
2. **Signing uses `RegionName`.** A client with a `ServiceURL` now gets `AuthenticationRegion` set to the region `RegionName` names. A `fips-` pseudo region becomes its base region, as it already did for `RegionEndpoint` in proxy mode. Previously the signer took the region from `AWS_REGION`, the profile or `us-east-1`. A `RegionName` set to blank is allowed when `UseServiceUrl` is on or the compatibility overload is called with `true`: no signing region is set, and the SDK's own fallback still applies. Presigned S3 URLs for such a client point at the emulator and, with a non-blank `RegionName`, use it as the credential scope. Credentials still always come from the session.
Expand All @@ -35,6 +37,7 @@ These apply to clients built with `UseLocalStack: true`; with `UseLocalStack: fa
9. **With an explicit endpoint, S3 buckets get `RegionName` as their region.** `PutBucket` without `BucketRegion`, `BucketRegionName` or a `PutBucketConfiguration` location now creates the bucket in `RegionName` (no constraint for `us-east-1`, `EU` for `eu-west-1`), and `DeleteBucket` signs with `RegionName`, whatever `AWS_REGION` says. Without this, such a `PutBucket` failed on LocalStack and Floci outside `us-east-1`, because the AWS SDK took the bucket region from the endpoint host or the ambient region while it signed for `RegionName`. In 3.0.x, which also signed with the ambient region, such a bucket landed in `us-east-1` or the ambient region; it now lands in `RegionName`, as it always did in default proxy mode. A request that chooses its own region, or sets `UseClientRegion = false`, is unchanged.
10. **`ISessionReflection.SetClientRegion` keeps an explicit endpoint.** A client with a `ServiceURL` keeps it and signs for the new region through `AuthenticationRegion`; its `RegionEndpoint` is left as it was. 3.0.x assigned `RegionEndpoint`, which made the AWS SDK clear `ServiceURL`; with `useServiceUrl: true` the 3.0.x proxy then still carried the request to the emulator, but in 3.1 an explicit-endpoint client has no proxy, so it would have targeted the regional AWS host. A proxy-mode client is unchanged: it gets the new `RegionEndpoint` and keeps its proxy. Assigning `Config.RegionEndpoint` directly still clears `ServiceURL`, as the README notes.
11. **`UseSsl: true` selects a direct HTTPS endpoint** when no AWS-standard endpoint applies. In 3.0.x both the default path and `useServiceUrl: true` sent HTTPS through the emulator's proxy, which could not tunnel it. Set up the emulator's TLS listener and certificate trust for 3.1. See [HTTPS and certificate trust](README.md#https-and-certificate-trust).
12. **`GetServiceUrl` defaults to the edge port.** An already-compiled call such as `AwsServiceEndpointMetadata.S3.GetServiceUrl("http", "host")` still binds, but now uses port 4566 instead of the former per-service port (4572 for S3). An explicit port is unchanged.

### Fixed

Expand All @@ -48,7 +51,7 @@ These apply to clients built with `UseLocalStack: true`; with `UseLocalStack: fa
- CI runs on and publishes GitHub Packages previews from `release/**` integration branches.
- Added endpoint precedence tests: fast `SessionEndpointPrecedenceTests` (profile endpoints through an injected helper, on both `Type` paths), an Integration test for a service-specific profile endpoint with real S3 and SNS clients, a JIT-fallback generator test, and functional scenarios that run a probe container for twelve cases against two emulators on each tested backend. The existing proxy assertions for `useServiceUrl: true` (Native AOT `AssertClient`, Integration `AssertClientConfiguration` and the Extensions DI test) now expect no proxy and `AuthenticationRegion`; the functional `GetScenarioClient` checks the `ServiceURL` when one is set, and the proxy otherwise.
- The shared functional scenarios also run in service-URL mode (`LocalStack:Config:UseServiceUrl=true`) on each tested backend, and every endpoint precedence case runs with the setting off and on. A new offline test creates every cataloged client with the proxy default, the setting, an AWS-standard endpoint from a profile, and both.
- Package validation now compares with 3.0.0 instead of 2.0.0. The removed `useServiceUrl` overloads are recorded in `CompatibilitySuppressions.xml` for both packages.
- Package validation now compares with 3.0.0 instead of 2.0.0. The removed `useServiceUrl` overloads are recorded in `CompatibilitySuppressions.xml` for both packages; the legacy-port API removals are recorded only for Core.
- Added S3 bucket-region tests (`S3BucketRegionTests`, offline) and SDK contract tests (`S3BucketRegionContractTests`) for every AWS SDK internal the new S3 handler relies on, including its removal condition. Offline Integration tests now stop requests after signing through a pipeline handler instead of a replaced `HttpClientFactory`, which the `net472` SDK lacks. The Native AOT lane creates, locates and deletes a bucket with the service-URL setting.
- Added read-order contract tests (`EndpointReadOrderContractTests`, in the Integration tests, run by the canary). Plain SDK rows pin that an AWS-standard endpoint survives client creation except when `ServiceURL` is read before the constructor with no explicit region, and library rows assert that every creation path (static factory, both interface and implementation overloads, `AddAwsService`, the reflection fallback and a data-plane client) keeps it, on the endpoint the client resolves.
- Added AWS SDK endpoint contract tests (`AwsStandardEndpointContractTests`, in the Integration tests). They exercise only the AWS SDK and pin how a plain client configuration resolves `ServiceURL` from the standard endpoint settings, which the endpoint precedence relies on: variable and profile order, both ignore switches, an empty value, and the service-specific variable name derived from the service ID. The scheduled AWS SDK canary runs them, so an SDK change to that resolution fails there first.
Expand Down
2 changes: 1 addition & 1 deletion GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The AWS SDK service identifier used to match a service to this library's endpoin
_Avoid_: CLI name, enum name, or an unqualified service name for this identifier.

**Configured LocalStack endpoint**:
The host, scheme, and port this library associates with a cataloged AWS service. Several services can share a port, and the configured endpoint alone does not establish which operations the emulator supports.
The host, scheme, and shared edge port this library associates with a cataloged AWS service. The configured endpoint alone does not establish which operations the emulator supports.
_Avoid_: AWS region or service ID as synonyms for an endpoint.

**LocalStack mode / AWS mode**:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ app.Run();
| `LocalStack:Session:RegionName` | `us-east-1` |
| `LocalStack:Config:LocalStackHost` | `localhost.localstack.cloud` |
| `LocalStack:Config:UseSsl` | `false` (see [HTTPS and certificate trust](#https-and-certificate-trust)) |
| `LocalStack:Config:UseLegacyPorts` | `false` (only for LocalStack before 0.11.5) |
| `LocalStack:Config:EdgePort` | `4566` |
| `LocalStack:Config:UseServiceUrl` | `false` (see [endpoint precedence](#endpoint-precedence)) |

Expand Down Expand Up @@ -202,7 +201,7 @@ using var s3ByInterface = session.CreateClientByInterface<IAmazonS3>();
```

The `Type`-based overloads are `CreateClientByImplementation(Type implType)` and `CreateClientByInterface(Type serviceInterfaceType)`.
For service-URL mode, pass `new ConfigOptions(localStackHost, useSsl, useLegacyPorts, edgePort, useServiceUrl: true)`.
For service-URL mode, pass `new ConfigOptions(localStackHost, useSsl, edgePort, useServiceUrl: true)`.

## Native AOT and trimming

Expand Down
18 changes: 6 additions & 12 deletions docs/adr/0003-edge-port-and-legacy-compatibility.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# Use the LocalStack edge port and remove legacy per-service ports

Status: accepted (3.1, implementation pending)

Decision date: 2026-11-29. This decision replaces the earlier decision of this record; both stay below until the 3.1 implementation ships, as the [ADR guide](README.md) requires for a pending decision.

**Earlier decision (the behavior of 3.0.x, and of any build until 3.1 ships).** `ConfigOptions` defaults to the shared edge endpoint on port 4566 with `UseLegacyPorts=false`, and `UseLegacyPorts` stays as an explicit opt-in for consumers who need the per-service port mappings of the endpoint catalog.

**Current decision (3.1).** The edge port is the only port model. The library removes `UseLegacyPorts`, the matching `ConfigOptions` constructor parameter, `Constants.UseLegacyPorts`, the per-service port metadata of the endpoint catalog, and every code path that existed only to select those ports; the exact list of removed public members is stated in the change and the changelog. `EdgePort` stays, because the host port of a container is often remapped. The service catalog itself (service IDs, CLI names and catalog keys) stays.
The edge port is the only port model. The library removes `UseLegacyPorts` and the per-service port APIs and metadata listed in the [changelog](../../CHANGELOG.md#breaking-changes). `EdgePort` stays, because the host port of a container is often remapped. The service catalog itself (service IDs, CLI names and catalog keys) stays.

## Why

LocalStack removed per-service ports in [v0.11.6 (2020-10-02)](https://github.com/localstack/localstack/releases/tag/v0.11.6) and serves every service through the edge port; the per-service `<SERVICE>_PORT_EXTERNAL` settings went in LocalStack 3.0. The README already restricts `UseLegacyPorts` to LocalStack before 0.11.5, so the option has had no working use against a supported emulator for years. Floci, also a tested backend, has one port and no per-service ports. Keeping the option costs a second port table that must be maintained alongside the catalog, dead branches in endpoint creation, and a configuration key that suggests a capability the emulators no longer have ([#26](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/26)).
LocalStack removed per-service ports in [v0.11.6 (2020-10-02)](https://github.com/localstack/localstack/releases/tag/v0.11.6) and serves every service through the edge port; the per-service `<SERVICE>_PORT_EXTERNAL` settings went in LocalStack 3.0. Floci, also a tested backend, has one port and no per-service ports. Keeping the option costs a second port table that must be maintained alongside the catalog, dead branches in endpoint creation, and a configuration key that suggests a capability the emulators no longer have ([#26](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/26)).

## Alternatives

Expand All @@ -20,10 +14,10 @@ LocalStack removed per-service ports in [v0.11.6 (2020-10-02)](https://github.co

## Consequences

- **A deliberate break in a minor release.** A caller that passes the removed constructor parameter, or reads the removed members, no longer compiles. The owner accepts this risk; the changelog lists it as a breaking change, and the intentional breaks are recorded in the package-validation compatibility suppressions while the 3.0.0 baseline stays.
- **Old configuration still loads.** The options binder ignores a leftover `LocalStack:Config:UseLegacyPorts` key without failing; this is ordinary options-binding behavior, and the changelog says so. A configuration that set it to `true` now silently uses the edge port, which is the only port a supported emulator serves.
- **The Aspire hosting integration** stops emitting that key. The [identical-value contract](0005-endpoint-precedence-and-signing-region.md) never included it.
- **A deliberate break in 3.1.** Callers using the removed constructor or members must migrate and recompile. The intentional breaks are recorded in the package-validation compatibility suppressions against the 3.0.0 baseline.
- **Old configuration still loads.** The options binder ignores a leftover `LocalStack:Config:UseLegacyPorts` key for any value and uses `EdgePort`.
- **The Aspire hosting integration** does not need to emit that key. The [identical-value contract](0005-endpoint-precedence-and-signing-region.md) never included it.
- **`EDGE_PORT`, `USE_SSL` and `LOCALSTACK_HOST` are not read.** The library reads no environment variable of its own and takes only `LocalStack:*` configuration. LocalStack removed `EDGE_PORT` in 3.0, `USE_SSL` no longer toggles TLS there, and `LOCALSTACK_HOST` is a container setting that shapes URLs the emulator returns, not a client discovery variable ([#25](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/25) closes as obsolete). A user who needs the AWS-standard endpoint variables gets them through [endpoint precedence](0005-endpoint-precedence-and-signing-region.md).
- Current mapping behavior is owned by the [client runtime](../architecture/client-runtime.md), which describes the legacy catalog ports until the change lands.
- The [client runtime](../architecture/client-runtime.md) describes how the library configures a cataloged service.

**References:** [Configuration options](../../src/LocalStack.Client/Options/ConfigOptions.cs), [endpoint configuration](../../src/LocalStack.Client/Config.cs), [endpoint catalog](../../src/LocalStack.Client/Enums/AwsServiceEndpointMetadata.cs), and the [earlier maintainer explanation](https://github.com/localstack-dotnet/localstack-dotnet-client/issues/5#issuecomment-775340238).
Loading
Loading