# AWS API

It's possible to interact with different AWS services that support access via HTTP API and [Signature V4 signing](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) using the AWS API Connection.

An example of such request could be the *creation of an S3 bucket*. Let's review the steps needed to implement this use case in UI Bakery:

1. [Create a new IAM user](https://docs.uibakery.io/reference/amazon-s3#creating-iam-user).

{% hint style="danger" %}
When running UI Bakery in the *Production* environment, we strongly recommend limiting IAM user's access only to the operations they are allowed to perform. For more information, please refer to [AWS documentation](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html).
{% endhint %}

2. [Generate Access key ID and Secret Access key ID](https://docs.uibakery.io/reference/amazon-s3#generating-access-key-id-and-secret-key-id).
3. [Connect UI Bakery AWS API data source](#connecting-ui-bakery-aws-api-data-source).
4. [Create an S3 bucket via UI Bakery action](#creating-an-s3-bucket-via-ui-bakery-action).

## Configuration

### Connecting the UI Bakery AWS API data source

1. On the **Data sources** page, click **Connect**, and select *AWS API* in the Data sources list.
2. Paste the **Access key ID** and **Secret access key ID** you've created before.
3. Configure the *region* where you want to create your bucket, for example, `us-west-2`.\
   For the *AWS service* name, use `s3`.
4. Click **Test connection** to check whether the data source can be connected, and then click **Connect Datasource**.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FtJ3vvqR6JZzyzTkFa7is%2FCleanShot%202025-04-08%20at%2014.33.33%402x-min.png?alt=media&#x26;token=a8c00845-b9a9-4664-991d-e2cefb50d2cd" alt=""><figcaption></figcaption></figure>

## Usage

### Creating an S3 bucket via UI Bakery action

Once your datasource is configured, you can go to your project and open the actions panel. There, create a new action of the [HTTP Request](https://docs.uibakery.io/reference/working-with-actions/http-request) type and select the datasource you configured in the previous step.

According to [AWS S3 API](https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html), in order to create an S3 bucket, you need to send a *PUT* request to `https://<your-new-bucket-name>.s3.<your-aws-region>.amazonaws.com` with the *body* containing the following XML (replace `LocationConstraint` contents with your region):

```xml
<?xml version="1.0" encoding="UTF-8"?>
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
   <LocationConstraint>us-west-2</LocationConstraint>
</CreateBucketConfiguration>
```

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FaGNUP8s8HW6BfqFPuRg7%2FCleanShot%202025-04-08%20at%2015.06.23%402x-min.png?alt=media&#x26;token=9fb2e255-ecdc-4705-9b35-a5ff8fab5c76" alt=""><figcaption></figcaption></figure>

Once the action is configured, you can execute it and check if the S3 bucket was created.

{% hint style="info" %}
You can set the bucket name dynamically in the URL field based on the value of some input. For more information, refer to [this article](https://docs.uibakery.io/concepts/working-with-variables).
{% endhint %}
