> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/app/setting-up-your-database/snowflake/connecting-to-snowflake/snowflake-temp-storage-aws.md).

# AWS - Setting the storage location for temporary files

During data generation, Structural uses temporary CSV files to load and unload Snowflake tables.

To store the temporary files, you can either:

* Use external stages instead of S3 buckets.
* Provide separate paths for the source and destination files.

## Setting the type of storage to use <a href="#snowflake-aws-connection-storage-type" id="snowflake-aws-connection-storage-type"></a>

By default, the temporary files are stored in S3 buckets.

To instead use external stages, toggle **Use External Stage** to the on position.

## Enabling separate paths for source and destination files <a href="#snowflake-aws-connection-separate-source-dest" id="snowflake-aws-connection-separate-source-dest"></a>

By default, you provide a single S3 bucket path or external stage. Within that path:

* Structural copies the files that contain the source data into an `input` folder.
* After it applies the generators, Structural copies the files that contain the destination data into an `output` folder.

To instead provide separate paths for the source and destination files, toggle **Use Separate Destination Location** to the on position.

## Setting S3 bucket locations <a href="#snowflake-aws-connection-source-s3-bucket" id="snowflake-aws-connection-source-s3-bucket"></a>

When **Use External Stage** is off, then you provide the S3 buckets to use.

If **Use Separate Destination Location** is off, then in the **S3 Bucket Path** field, specify the S3 bucket.

If **Use Separate Destination Location** is on, then:

1. In the **Source S3 Bucket** field, enter the path to the S3 bucket to use for the source files.
2. In the **Destination S3 Bucket** field, enter the path to the S3 bucket to use for the destination files.

## Setting external stage locations <a href="#snowflake-aws-connection-external-stages" id="snowflake-aws-connection-external-stages"></a>

If **Use External Stage** is on, then you provide external stage locations instead of S3 buckets. For each stage, the format is:

`<database>.<schema>.<stage>`

Where:

* `<database>` is the name of the database where the stage is located.
* `<schema>` is the name of the schema that contains the stage.
* `<stage>` is the name of the stage.&#x20;

If **Use Separate Destination Location** is off, then in the **Source Snowflake External Stage Name** field, enter the external stage.

If **Use Separate Destination Location** is on, then:

1. in the **Source Snowflake External Stage Name** field, enter the external stage to use for the source files.
2. In the **Destination Snowflake External Stage Name** field, enter the external stage to use for the destination files.

## Providing AWS credentials for storage locations <a href="#snowflake-azure-storage-location-aws-credentials" id="snowflake-azure-storage-location-aws-credentials"></a>

For each S3 bucket or external stage, you provide the credentials to use connect to it.

### Selecting the type of credentials to use <a href="#aws-storage-credentials-type" id="aws-storage-credentials-type"></a>

Under **AWS Credentials**, click the type of credentials to use. The options are:

* **Environment -** Only available on self-hosted instances.\
  \
  Indicates to use either:
  * The credentials for the IAM role on the host machine.
  * The credentials set in the following [environment settings](/app/admin/environment-variables-setting.md):
    * `TONIC_AWS_ACCESS_KEY_ID` - An AWS access key that is associated with an IAM user or role.
    * `TONIC_AWS_SECRET_ACCESS_KEY` - The secret key that is associated with the access key.
    * `TONIC_AWS_REGION` - The AWS Region to send the authentication request to.
  * The credentials in a credentials file.
* **Assume role -** Indicates to use a specified assumed role.
* **User credentials -** Indicates to use the provided user credentials.

### Providing an assumed role <a href="#aws-storage-assumed-role" id="aws-storage-assumed-role"></a>

To provide an assumed role, click **Assume Role**, then:

1. In the **Role ARN** field, provide the Amazon Resource Name (ARN) for the role.
2. In the **Session Name** field, provide the role session name.\
   \
   If you do not provide a session name, then Structural automatically generates a default unique value. The generated value begins with `TonicStructural`.
3. In the **Duration (in seconds)** field, provide the maximum length in seconds of the session. \
   \
   The default is `3600`, indicating that the session can be active for up to 1 hour.\
   \
   The provided value must be less than the maximum session duration that is allowed for the role.
4. From the **AWS Region** dropdown list, select the AWS Region to send the authentication request to.

For each assumed role, Structural generates the external ID that is used in the assume role request. Your role’s trust policy must be configured to condition on your unique external ID.

Here is an example trust policy:

```json
{
  "Version": "2012-10-17",
  "Statement": {
    "Effect": "Allow",
    "Principal": {
      "AWS": "<originating-account-id>"
    },
    "Action": "sts:AssumeRole",
    "Condition": {
      "StringEquals": {
        "sts:ExternalId": "7aab6da2-62ed-fae9-efb5-03b3b4daed8a"
      }
    }
  }
}
```

### Providing AWS user credentials <a href="#aws-storage-user-credentials" id="aws-storage-user-credentials"></a>

To provide AWS credentials, click **User Credentials**, then:

1. In the **AWS Access Key** field, enter the AWS access key that is associated with an IAM user or role.
2. In the **AWS Secret Key** field, enter the secret key that is associated with the access key.
3. From the **AWS Region** dropdown list, select the AWS Region to send the authentication request to.

## Testing the storage location connection <a href="#storage-location-test-connection" id="storage-location-test-connection"></a>

To verify that Structural is able to use the provided credentials to connect to the storage location, click **Test Source Object Storage**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.tonic.ai/app/setting-up-your-database/snowflake/connecting-to-snowflake/snowflake-temp-storage-aws.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
