# Language SDKs to Use with LocalStack

Is your application interacting with Amazon Web Services? No worries! AWS provides client libraries and SDKs for a wide range of programming languages, here are just a few of them:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693153265275/5570f6a3-9b13-4678-be29-2e18d202b8ee.png align="center")

As promised, LocalStack can be a drop-in replacement for the most popular AWS services, which means there are many ways of easily configuring your clients to point to a different endpoint.

These client libraries allow developers to interact with various AWS/LocalStack services and APIs more easily and efficiently from within your preferred programming language. Each SDK typically provides a set of APIs, classes, and methods that abstract the low-level details of making HTTP requests and handling authentication, making it easier to integrate AWS services into your applications.

The **TL;DR** part: Here are some easy ways you can configure an S3 client in a few different other languages. Notice how similar they are and how you can always transition between AWS and LocalStack with just a few variables:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693155761313/92e392ca-905c-4b79-8892-a59f580ed193.png align="center")

This will be a follow-along type of article :). Let’s have a look at an S3 Java client.

1. Clone the repository.
    
    ```bash
    git clone <https://github.com/tinyg210/stack-bytes-apigw-lambda-s3.git>
    ```
    
2. Export your `LOCALSTACK_API_KEY` as an environment variable.
    
    ```bash
    export LOCALSTACK_API_KEY=<YOUR_API_KEY>
    ```
    
    \*Sidenote: make sure there’s `apigw-lambda.jar` in the `/stack-bytes-lambda/target/` folder. If not, or if anything fails, please run `mvn clean package shade:shade` in the `stack-bytes-lambda` folder.
    
3. Start LocalStack (we stay in the root folder).
    
    ```bash
    docker compose up
    ```
    
    Let’s have a look at our setup’s diagram:
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693154088522/b86024f7-0150-46f7-b881-d318932105a6.png align="center")
    
    Notice how we have a small Java app, with an S3 client (in the `S3Configs` class) on the right-hand side.
    
4. Switch to the `stack-bytes-sdk` folder where the new app resides.
    
    ```bash
    cd stack-bytes-sdk
    ```
    
    ```bash
    mvn clean package
    ```
    
    The S3 Java Client:
    
    ```java
    private static final String ACCESS_KEY = "test";
    private static final String SECRET_KEY = "test";
    
    private static final String LOCALSTACK_ENDPOINT = "https://s3.localhost.localstack.cloud:4566";
      
    private static Region region = Region.US_EAST_1;
      protected static final String BUCKET_NAME = "quotes";
      // create an S3 client
      protected static S3Client s3Client = S3Client.builder()
          .endpointOverride(URI.create(LOCALSTACK_ENDPOINT))
          .credentialsProvider(StaticCredentialsProvider.create(
              AwsBasicCredentials.create(ACCESS_KEY, SECRET_KEY)))
          .region(region)
          .build();
    ```
    
    The Java SDK client has an easy and intuitive way of adding the necessary configurations so that everything can be replaced with real values and continue to work on the AWS platform.
    
5. Let’s post a file to the S3 bucket using our new client in the S3PostRequest class:
    
    ```bash
    mvn exec:java -Dexec.mainClass="s3service.S3PostRequest"
    ```
    
    This will take an existing file in the `src/main/resources` folder and add it to the quotes bucket.
    
6. Let’s read it now, using the same client:
    
    ```bash
    mvn exec:java -Dexec.mainClass="s3service.S3GetRequest"
    ```
    
    ```bash
    Object text: Author: Fiona
    Quote: I want what any princess wants - to live happily ever after... with the ogre I married.
    ```
    
7. Now, let’s retrieve the same object using a different client and the dedicated Lambda function:
    
    ```bash
    curl --location 'http://id12345.execute-api.localhost.localstack.cloud:4566/dev/quoteApi?author=Fiona'
    ```
    
    ```bash
    {"text":"Quote: I want what any princess wants - to live happily ever after... with the ogre I married."}
    ```
    

The output formats differ, as this is the processed output of the GET Lambda, but essentially, they are the same.

For this case, we used the Java client, but don’t worry, the [LocalStack Developer Hub](https://docs.localstack.cloud/applications/) is packed with examples using different other programming languages.

Nothing can stop you from using LocalStack as a drop-in replacement for AWS now. With minimal configurations, your applications won’t know the difference.
