# Create a Redshift Test Warehouse

## Overview

The test warehouse feature allows you to follow good software development practices by enabling you to test your code in a non-production environment before merging your changes into production.  Follow these steps to create your test warehouse

In AWS:

1. [Create a snapshot of your Redshift Cluster](#creating-a-snapshot-in-redshift)
2. [Restore the snapshot to the Provisioned Cluster](#restore-the-snapshot)
3. [Make the Cluster is publicly accessible](#make-the-cluster-publicly-accessible)

In the Daasity App:

1. [Navigate to Warehouse Page](#navigate-to-the-warehouse-page)
2. [Enter Warehouse information](#enter-warehouse-information)
3. [Test the connection](#test-the-connection)
4. [Destroy the Test Warehouse](#destroy-test-warehouse)

### Creating a snapshot in Redshift

Login into your AWS Redshift Console

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/5yPsuYv4KBXngRC05Dbc/image.png" alt=""><figcaption></figcaption></figure>

Click on your cluster

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/gkh4KropWZYkziUCOnLh/image.png" alt=""><figcaption></figcaption></figure>

Navigate to Actions

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/6CNgh7w7mt3po3c4F0tG/image.png" alt=""><figcaption></figcaption></figure>

Click "Create Snapshot"

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/JXcdUUD1t9VGXJGQq85Z/image.png" alt=""><figcaption></figcaption></figure>

Give the snapshot a name and select the retention period for the backup.  We recommend a the shortest amount of time as we only need this snapshot to provision a test warehouse

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/BtDTcE7U5RtSILcBe4Me/image.png" alt=""><figcaption></figcaption></figure>

### Restore the snapshot

Once the snapshot has been created, find the snapshot by clicking on the cluster you backed up and navigate to the snapshot screen

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/t1ef1XGBuFFLFGY7srGL/image.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/nleBMDBor4ghCfZYw3co/image.png" alt=""><figcaption></figcaption></figure>

From the "Restore Snapshot" dropdown select "Restore to provisioned cluster"

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/I0ZipMPXfkPwkXdRFTYd/image.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/RV5x5LVPbHfIxEvpeXLK/image.png" alt=""><figcaption></figcaption></figure>

Give the cluster a name, select "Production" and make sure to choose the appropriate Node type and number of nodes

{% hint style="info" %}
You should select the same Node type and Number of nodes as the original cluster that you are copying
{% endhint %}

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/obiC5h4e2oAEemjuE1oa/image.png" alt=""><figcaption></figcaption></figure>

In the "Cluster permissions" make sure to add the correct IAM roles

{% hint style="danger" %}
You will not be able to access the Test Warehouse within Daasity if you do not add the correct IAM roles
{% endhint %}

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/mzeeScnaw4C3TAM9Zt92/image.png" alt=""><figcaption></figcaption></figure>

### Make the cluster publicly accessible

Click on the test cluster from the main page

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/rMFh8fSBLvtlb0J5s4qT/image.png" alt=""><figcaption></figcaption></figure>

Click on "Properties"

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/XRW9tTW1dVuKv0Z5fvtO/image.png" alt=""><figcaption></figcaption></figure>

And set the permissions to "Publicly Accessible"

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/hcIx97qOFNHnqkA7sY8J/image.png" alt=""><figcaption></figcaption></figure>

### Navigate to the Warehouse page

In the Daasity App navigate to the Warehouse page

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/EfrvbLkRIDezZYVucwha/image.png" alt="" width="229"><figcaption></figcaption></figure>

### Enter warehouse nformation

You will need to enter connection information for your Redshift Cluster

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/TONt8kIlbCOVuRIImhK6/image.png" alt=""><figcaption></figcaption></figure>

You can get this information from AWS

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/lDHsxwIvKD5V3Sfc4QOo/image.png" alt=""><figcaption></figcaption></figure>

And enter into the Daasity App

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/4USh68bFmlOuNS2NT7N7/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Make sure to delete all the information after the .com that was copied over
{% endhint %}

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/DeFduPJAS9Ml3FYz5Bz7/image.png" alt=""><figcaption></figcaption></figure>

Will become

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/ayMB1bFR5CxDEjQnvGdL/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
You can copy the Port Number, Database Name, User Name and User Password from your production warehouse as these will be the same
{% endhint %}

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/Rja6gC6DZ1WvaWCcVKcl/image.png" alt=""><figcaption></figcaption></figure>

### Test the connection

Once the information has been added test the connection by clicking on "Test Connection"

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/sQPRYvNcKO2OouVW8geN/image.png" alt=""><figcaption></figcaption></figure>

Once the test passes click on "Provision Test Warehouse" to complete setup

<figure><img src="https://content.gitbook.com/content/amTMWiPne1v1V3L7mbuj/blobs/IXiphFkUtTrm0trPzbJV/image.png" alt=""><figcaption></figcaption></figure>

### Destroy test warehouse

Your test warehouse is a one-time snapshot of your production warehouse and thus you should destroy the test warehouse once your testing is complete.  In order to destroy the test warehouse you will need to delete the cluster in Redshift and then destroy the test warehouse in the Daasity App
