> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starsheet.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic Setup

> Setting up a project using Starsheet's Cloudformation to setup resources automatically on AWS

Starsheet provides a template to automatically create the necessary resources on your AWS account in just a few clicks. It uses [Cloudformation](https://aws.amazon.com/cloudformation/), which is an AWS service to create a "stack" of resources based on a template.

If you choose the automated setup, you will be directed to AWS  when setting up your project. Once the Cloudformation stack has been deployed on AWS you should return to the setup page to complete setting up your Starsheet project.

## Permissions

Our Cloudformation template grants Starsheet with the minimal set of permissions required to function. Access is limited to only the resources that the Cloudformation template creates, and only the minimal set of permissions required is granted.

<Accordion title="Details of IAM Permissions Granted">
  The following permissions are granted to **only the specific S3 bucket and Cloudfront distribution** created by the template.

  **S3**

  | Permission        | Why it's needed                                                                                                                                                                        |
  | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `s3:PutObject`    | Used to upload the data generated from your Google Sheet(s) to your S3 bucket                                                                                                          |
  | `s3:DeleteObject` | Used to delete an item from S3 when you perform an action in Startsheet to initiate a deletion (such as deleting an environment). Starsheet never deletes data unless you initiate it. |
  | `s3:PutObjectAcl` | Used to set permissions on an item to make them publicly available or private.                                                                                                         |
  | `s3:GetObject`    | Used to copy a content version to an environment when publishing to an environment                                                                                                     |

  **Cloudfront**

  | Permission                      | Why it's needed                                                                                                                                                                                                                                      |
  | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `cloudfront:GetDistribution`    | Used by Starsheet to get the Cloudfront Domain Name and any Custom Domain Names mapped to the Cloudfront Distribution, which are used to generate the correct content URLs in the Startsheet application.                                            |
  | `cloudfront:CreateInvalidation` | When publishing content to an environment, Starsheet will automatically create an invalidation request to clear Cloudfront's CDN cache of old versions of the content to ensure that new requests return the updated content as quickly as possible. |

  You can verify this manually by viewing the [Cloudfront Template](https://starsheet-cloudformation-templates.s3.amazonaws.com/latest.json) file that Starsheet uses.
</Accordion>

## Setup Instructions

After selecting your Google Sheet, select 'Automatic AWS Setup' and follow these steps:

<Steps>
  <Step title="Click the 'Deploy Starsheet Stack to AWS'">
    This will direct you to AWS. Create a new account if you do not already have one or log in to an existing account.

    <Frame>
      <img src="https://mintcdn.com/starsheet/nbS5LRnBRewo-ERg/images/setup/automatic_setup_step_1.png?fit=max&auto=format&n=nbS5LRnBRewo-ERg&q=85&s=058bfe9be22cef34ef5e41188596a45d" width="2940" height="1596" data-path="images/setup/automatic_setup_step_1.png" />
    </Frame>
  </Step>

  <Step title="Give your stack a name">
    The name will be used in the resource created. For example the S3 bucket created will
    use the format `starsheet-{YOUR_STACK_NAME}-{GENERATED_UNIQUE_ID}`.

    <Info>The generated unique ID is added to prevent clashes because S3 bucket names must be globally unique across all AWS customers. </Info>

    <Frame>
      <img src="https://mintcdn.com/starsheet/nbS5LRnBRewo-ERg/images/setup/automatic_setup_step_2.png?fit=max&auto=format&n=nbS5LRnBRewo-ERg&q=85&s=e9c53e0cbc0a88bfa62c740716315ec4" width="2940" height="1596" data-path="images/setup/automatic_setup_step_2.png" />
    </Frame>
  </Step>

  <Step title="Acknowledge that you understand the stack will create an IAM Role">
    <Frame>
      <img src="https://mintcdn.com/starsheet/nbS5LRnBRewo-ERg/images/setup/automatic_setup_step_3.png?fit=max&auto=format&n=nbS5LRnBRewo-ERg&q=85&s=e9c76eba14489484eeb27f18db473bff" width="2940" height="1596" data-path="images/setup/automatic_setup_step_3.png" />
    </Frame>
  </Step>

  <Step title="Click 'Create Stack' to begin creating the AWS resources">
    <Frame>
      <img src="https://mintcdn.com/starsheet/nbS5LRnBRewo-ERg/images/setup/automatic_setup_step_4.png?fit=max&auto=format&n=nbS5LRnBRewo-ERg&q=85&s=e99543ccd5b68179e3407c264d309aac" width="2940" height="1596" data-path="images/setup/automatic_setup_step_4.png" />
    </Frame>

    The deployment will take a few minutes to complete.
  </Step>

  <Step title="Once the status changes to CREATE_COMPLETE click on the 'Outputs' tab ">
    <Frame>
      <img src="https://mintcdn.com/starsheet/nbS5LRnBRewo-ERg/images/setup/automatic_setup_step_5.png?fit=max&auto=format&n=nbS5LRnBRewo-ERg&q=85&s=53be36395f80d37e324af65ddffd5446" width="2940" height="1596" data-path="images/setup/automatic_setup_step_5.png" />
    </Frame>
  </Step>

  <Step title="Copy the values form the outputs tab to the relevant fields in the project creation form">
    <Frame>
      <img src="https://mintcdn.com/starsheet/nbS5LRnBRewo-ERg/images/setup/automatic_setup_step_6.png?fit=max&auto=format&n=nbS5LRnBRewo-ERg&q=85&s=c22dd2b429756d0c545a74fef42049c7" width="2940" height="1596" data-path="images/setup/automatic_setup_step_6.png" />
    </Frame>

    Once you have copied all 4 values. Click on the 'Create Project' button to finish the setup process.
  </Step>
</Steps>
