diff --git a/content/en/user-guide/tools/transparent-endpoint-injection/_index.md b/content/en/user-guide/tools/transparent-endpoint-injection/_index.md index 9c3eae6978..242ff8912d 100644 --- a/content/en/user-guide/tools/transparent-endpoint-injection/_index.md +++ b/content/en/user-guide/tools/transparent-endpoint-injection/_index.md @@ -8,10 +8,21 @@ aliases: - /tools/local-endpoint-injection/ --- -In the community (open source) edition, the application code needs to configure each AWS SDK client instance with the target `endpoint URL` to point to the APIs on `localhost` or, in the case of Lambdas running in the context of LocalStack, the `endpoint URL` should point to `http://${LOCALSTACK_HOSTNAME}:${EDGE_PORT}`. +In the community (open source) edition, +the application code needs to configure the `endpoint URL` of each AWS SDK client instance to target LocalStack +using the environment variable `AWS_ENDPOINT_URL` available within Lambda functions in LocalStack. +For example, a Python boto3 client can be configured as follows: -The Pro version provides two options for transparently making your application logic speak to the local APIs instead of real AWS (without having to change your production code): -1. integrated DNS server -2. patched AWS SDKs (**deprecated**) +```python +client = boto3.client("lambda", endpoint_url=os.environ['AWS_ENDPOINT_URL']) +``` -More details can be found in the subsections below. +For [supported AWS SDKs](https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html#ss-endpoints-sdk-compat) +(including boto3 since [1.28.0](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst#L892)), this configuration happens automatically without any custom code changes. + + +In LocalStack Pro, +no application code changes are required to let your application connect to local cloud APIs instead of real AWS because +LocalStack provides an integrated DNS server that resolves AWS API calls to target LocalStack. + +More details can be found in the subsection below. diff --git a/content/en/user-guide/tools/transparent-endpoint-injection/patched-sdks.md b/content/en/user-guide/tools/transparent-endpoint-injection/patched-sdks.md deleted file mode 100644 index ac6e19804b..0000000000 --- a/content/en/user-guide/tools/transparent-endpoint-injection/patched-sdks.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: "Patched AWS SDKs for Lambdas (Deprecated)" -categories: ["LocalStack Pro", "Tools"] -weight: 6 -description: > - Using patched SDKs in Lambdas to transparently redirect AWS API calls to LocalStack -aliases: - - /tools/local-endpoint-injection/patched-sdks/ ---- - -{{< alert title="Warning" color="warning">}} -Patched AWS SDKs for Lambdas are **deprecated** and only used by the old lambda provider. -The new lambda provider (active since LocalStack 2.0) uses DNS-based domain resolution (except for the Ruby runtime).
-Please refer to [Lambda providers]({{< ref "user-guide/aws/lambda" >}}) for more details about the new Lambda implementation. -{{< /alert >}} - -The Lambda runtime in LocalStack uses patched AWS SDKs, which are configured to target the local APIs instead of the real AWS. -This behavior is enabled by default for most Lambda runtimes when using LocalStack Pro. - -Assuming you had a Python Lambda handler that attempts to list all S3 buckets. In the past, you had to manually configure the `endpoint_url` parameter on the boto3 client (and potentially use environment switches for dev/prod in your test code): -```python -import boto3 -def handler(event, context): - client = boto3.client("s3", endpoint_url="http://localhost:4566") - print(client.list_buckets()) -``` - -With the patched AWS SDKs, it now becomes possible to deploy your unmodified production code to LocalStack, simply creating a boto3 client with default settings. The invocations of the boto3 client will be automatically forwarded to the local APIs: -```python -import boto3 -def handler(event, context): - client = boto3.client("s3") - print(client.list_buckets()) -``` - -{{< alert title="Note">}} -This functionality only works when using the SDKs provided by the Lambda execution environment itself. -If you choose to ship your own SDKs with your Lambda or using a layer, it will fallback to the [DNS based transparent execution]({{< ref "dns-server" >}}) if enabled, since those SDK versions will not be patched. -{{< /alert >}} - -This feature works by patching the AWS SDKs in the docker images, which provide the execution environment for Lambdas within LocalStack. - -The main advantage of this mode is, that no DNS magic is involved, and SSL certificate checks do not have to be disabled. - -## Configuration - -If you want to disable this behavior, and use the DNS server to resolve the endpoints for AWS, you can disable this behavior by using: - -```bash -TRANSPARENT_LOCAL_ENDPOINTS=0 -``` - -## Supported Runtimes -Currently, LocalStack supports patching the SDKs for the following runtimes: - -* Python (using boto3) -* NodeJS -* Ruby -* Java - -Also, these patched SDKs are only available in the following Lambda execution modes: - -* docker -* docker-reuse - -This feature is currently not supported for custom Lambda container images.