# AWS Cloud Setup

{% hint style="success" %}
dex provides a pre-configured [**CloudFormation template**](https://github.com/dexlabsio/terraform-modules/tree/main/aws/cloudformation) that automates cloud configuration. This guide walks you through each step of the setup.
{% endhint %}

To establish a secure and functional integration between dex and your AWS account, the following resources need to be created:

* Two dedicated **S3 buckets**: one for storing data, the other for metadata
* Two **Athena workgroups**: one for production, and another for development
* One **IAM user or role**: to allow dex to write data to your cloud storage

{% hint style="info" %}
Before running the CloudFormation template, confirm your AWS region. This determines where your buckets will be created. If your organization doesn’t have a preferred region, we recommend using `us-east-1`.
{% endhint %}

<a href="https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create?templateURL=https://dex-public-assets.s3.us-east-1.amazonaws.com/cloudformation/dex_roles.yaml" class="button primary">Access the CloudFormation Console</a>

<details>

<summary>Step 1: Create the Stack</summary>

1. Go to the **AWS CloudFormation Console** and click **Create Stack**.
2. Under **Prepare template**, select **Choose an existing template**.
3. For **Template source**, choose **Amazon S3 URL**.
4. Enter the following S3 URL for the deX CloudFormation template:

```
https://dex-public-assets.s3.us-east-1.amazonaws.com/cloudformation/dex_roles.yaml
```

This will load the dex automation script and prepare it for configuration.

</details>

<details>

<summary>Step 2: Specify Stack Details</summary>

* In **Stack name**, enter a name to identify this setup—for example, `dex-setup`.

Under **Parameters**:

* **CreateDexUser**: Select `True` to create an IAM user in your AWS account. This user will be used by dex Automation to write data to your cloud. These credentials will never be stored by deX.
* **InstallationID**: Enter the unique ID displayed in your deX workspace during the cloud connection step

{% hint style="danger" %}
If you choose to create the IAM manually, contact dex Support after setup to complete the integration
{% endhint %}

</details>

<details>

<summary>Step 3: Configure Stack Options</summary>

This step allows for advanced configuration, but for most users, the defaults are sufficient. However, we recommend reviewing these two settings to ensure a clean rollback in case of failure.&#x20;

Under **Stack failure options**:

* Set **Behavior on provisioning failure** to `Roll back all stack resources`
* Set **Delete newly created resources during a rollback** to `Use deletion policy`

</details>

<details>

<summary>Step 4: Review and Create</summary>

Review all the information entered in the previous steps. Once confirmed, click **Create Stack** to begin provisioning the resources.

{% hint style="info" %}
If your stack creation fails, reach out to dex Support for assistance.
{% endhint %}

</details>

<details>

<summary>Step 5: Finalize the Setup in deX</summary>

Go to the **Outputs** tab in your new stack and locate the `Access Key ID` and `Secret Access Key`. Copy and paste these credentials into the corresponding fields in the dex platform to complete the connection.

</details>


---

# 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.dexlabs.io/lakehouse-platform/set-up-dex/aws-cloud-setup.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.
