# Create a destination for AWS + S3 + Databricks or Snowflake

To populate your <u>**Amazon Web Services**</u> (<u>**AWS**</u>) + <u>**AWS S3**</u> repository with healthcare data from an EHR system via Redox (and then to optionally feed that data into <u>**Databricks**</u> or <u>**Snowflake**</u> for analytics), you must configure a specific <u>Redox cloud destination</u>. A Redox <u>destination</u> represents where a message is delivered (e.g., like the address in the “To” line of an email header). [Learn more about connecting Redox to your cloud repository](/basics/connecting-to-the-cloud-with-redox).

You'll need to perform some steps in your cloud product(s) and some in Redox. You can perform Redox setup in our dashboard or with the Redox Platform API. 

## Prerequisites

- Establish a connection with your preferred EHR system. [Learn how to request a connection](/how-to-use-redox/manage-your-redox-setup/request-a-connection-or-subscription).
- Decide which combination of <u>**cloud products**</u> to use. Redox currently supports any of these combinations with your AWS cloud repository: 
  1. <u>**AWS**</u> + <u>**AWS S3**</u>
  2. <u>**AWS**</u> + <u>**AWS S3**</u> + <u>**Databricks**</u>
  3. <u>**AWS**</u> + <u>**AWS S3**</u> + <u>**Snowflake**</u>
- Complete your AWS (and any other cloud product) configuration _before_ creating your Redox destination. Save any downloads with secret values, since you’ll need to enter some of these details into the Redox dashboard.
- Grant access to Redox from AWS (and any other cloud product) to authorize Redox to push data to your cloud repository.

## Configure in AWS

1. Navigate to the AWS dashboard and log in. 
2. [Create a new S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html).
3. [Create an IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html). 
4. Attach a policy to the IAM User that allows `PutObject` actions against the new S3 bucket.
5. [Generate an access key](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) and secret pair.
_Save the secret key, since it will only be visible_ _once. You'll need it for Redox setup later._ 

## Create a cloud destination in Redox

Next, create a <u>cloud destination</u> in your Redox organization. When the EHR system sends healthcare data to Redox, we push it on to your configured AWS + S3 cloud destination.

### In the dashboard

1. For the select destination step, [follow the instructions for creating a cloud destination](https://docs.redoxengine.com/permalink/5FMTxkOE7yrDCBgiqfV3Z7/#create-a-destination). 
   1. From the <u>Product type</u> field, select **Databricks** or **Snowflake** if you’re using one of those cloud products with AWS S3. Your S3 settings will be ingested with the additional cloud product. 
Select **S3** if you're not using either Databricks or Snowflake. 
2. For the configure destination step, populate these fields. Then click the **Next** button. 
   1. <u>**Bucket name**</u>: Enter the **S3 bucket name**. Locate this value in the AWS dashboard. 


> **Bucket naming requirements**
>
> We validate that the bucket name meets AWS’s naming requirements. [Review bucket naming rules](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).


   2. <u>**Object key prefix**</u> (optional): Enter any prefix you want prepended to new files when they're created in the S3 bucket. Add `/` to put the files in a subdirectory. For example, `redox/` puts all the files in the `redox` directory.
3. For the auth credential step, either a drop-down list of existing auth credentials displays or a new auth credential form opens. [Learn how to create an auth credential](https://docs.redoxengine.com/how-to-use-redox/manage-your-redox-setup/set-up-auth-credentials/#aws-signature-version-4) for AWS Sigv4.  


> **Existing or new auth credential**
>
> Your existing auth credentials will only display if they’re supported for the cloud product type you selected. If you don’t have any supported auth credentials for the cloud type in the current Redox environment, you’ll have to create a new auth credential.


4. For the verify step, [follow the instructions for verifying a destination](https://docs.redoxengine.com/permalink/5FMTxkOE7yrDCBgiqfV3Z7/#step-4-verify-destination). 

### With the Redox Platform API

1. [Review the Create auth credential endpoint](https://docs.redoxengine.com/permalink/dd0240f7-18d1-593d-87a7-d81bf86f543c-create-auth-cred).
2. In your terminal, prepare the `/v1/authcredentials` request.
3. Specify these values in the request. 
   - Locate the `accessKey` and `secretKey` values in the AWS dashboard.  


**Example: Create auth credential for AWS S3 + Databricks or Snowflake**

```json
curl 'https://api.redoxengine.com/platform/v1/authcredentials' \
--request POST \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
    "organization": "<Redox_organization_id>",
    "name": "<human_readable_name_for_auth_credential>",
    "environmentId": "<Redox_environment_ID>",
    "authStrategy": "AwsSigV4",
    "accessKey": "<access_key_from_AWS>",
    "secretKey": "<secret_key_from_AWS>",
    "serviceName": "s3",
    "awsRegion": "<aws_region_of_AWS_S3_bucket>"
  }
```


4. You should get a successful `200` response and a `payload` populated with the details of the new auth credential. 
5. [Review the Create destination endpoint](https://docs.redoxengine.com/permalink/96830826-bf9c-5d5a-878c-b5b3f1402f30-create-destination).
6. In your terminal, prepare the `/v1/environments/{environmentId}/destinations` request with these values: 
   - Set `authCredential` to the auth credential ID from the response you received in step #4.  
   - Populate `cloudProviderSettings` with these settings. 
     - Enter the `productId` based on your specific setup: 
       - <u>**S3 only**</u>: `s3`.
       - <u>**S3 + Databricks**</u>: `databricks`
       - <u>**S3 + Snowflake**</u>: `snowflake`
     - Locate the `bucketName` in the AWS dashboard. 
     - The `keyPrefix` is optional. If specified, it gets prepended to the created file path in AWS S3. You can append `/` after the prefix name to indicate a directory path.


**Example: Values for S3, Databricks, or Snowflake cloudProviderSettings**

```json
{
  "cloudProviderSettings": {
    "typeId": "aws",
    "productId": "<s3_databricks_or_snowflake>", 
    "settings": {
      "bucketName": "<bucket_name>",
      "keyPrefix": "<optional_prefix>"
     }
  }
}
```


7. You should get a successful `200` response with a `payload` populated with the details of the new AWS cloud destination. Specifically, the `verified` status of the destination should be set to `true`. 
8. Your new destination will now be able to receive messages. Each message pushed to this destination will create files in the S3 bucket. The uploaded file will be named based on the log ID of the message. 
