# 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](/reference/data-sources/amazon-s3.md#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](/reference/data-sources/amazon-s3.md#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="/files/JjUZ7ooS6c6Ci1zBEUxG" 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](/reference/working-with-actions/http-request.md) 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="/files/ddmXmJKjZh0GtV02hqCv" 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](/concepts/working-with-variables.md).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.uibakery.io/reference/data-sources/aws-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
