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

# AWS EC2 Setup

> Guide for setting up AWS EC2 to install ale.

<Note>
  For optimal performance of `ale`, we recommend:

  * Instance type **t3.large(2vCPU, 8GiB)** or higher
  * **amd64(x86\_64)** architecture OS
  * **60GiB** or more storage
</Note>

***

## Launch EC2 Instance

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/02_01.png" />
</Frame>

> Click `Launch instances` in `EC2 > Instances`.

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/02_02.png" />
</Frame>

> Enter or select the instance information as follows:

* Name and tags
  * Name: Instance name
* Application and OS Images (Amazon Machine Image)
  * Amazon Machine Image (AMI): Ubuntu Server 24.04 LTS (amd64)
* Instance type
  * Select type t3.large or higher specification
* Key pair (login)
  * Select the key pair created in the previous step

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/02_03.png" />
</Frame>

> Configure **6 Security group rules** and storage settings as follows:

* Network settings
  * VPC: Target VPC for EC2 provisioning. Must be able to communicate with the internet
  * Subnet: Select public subnet with internet gateway connected
  * Auto-assign public IP: Enable
  * Firewall (security groups)

    * Select Create security group and enter appropriate security group name
    * Security group name: Name for security group
    * Description: Security group description
    * Add security group rules

    <CardGroup cols={3}>
      <Card title="rule_01">
        - Type: SSH
        - Protocol: TCP
        - Port range: 22
        - Source: 0.0.0.0/0
      </Card>

      <Card title="rule_02">
        * Type: HTTP
        * Protocol: TCP
        * Port range: 80
        * Source: 0.0.0.0/0
      </Card>

      <Card title="rule_03">
        * Type: HTTPS
        * Protocol: TCP
        * Port range: 443
        * Source: 0.0.0.0/0
      </Card>

      <Card title="rule_04">
        * Type: Custom TCP
        * Protocol: TCP
        * Port range: 6443
        * Source: 0.0.0.0/0
      </Card>

      <Card title="rule_05">
        * Type: Custom TCP
        * Protocol: TCP
        * Port range: 9001
        * Source: 0.0.0.0/0
      </Card>

      <Card title="rule_06">
        * Type: Custom TCP
        * Protocol: TCP
        * Port range: 9009
        * Source: 0.0.0.0/0
      </Card>
    </CardGroup>

* Configure storage
  * 1 x 60GiB, select gp3

## Associate Elastic IP Address

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/02_04.png" />
</Frame>

> Go to `EC2 > Network & Security > Elastic IPs`, click the IP allocated in the previous step, then click `Associate Elastic IP address`. Enter the following information to associate:

* Resource type: Instance
* Instance: Select the EC2 instance created in the previous step
* Private IP: Private IP address of the EC2 instance

## Connect to EC2 and Install Packages

<Frame>
  <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/02_05.png" />
</Frame>

> Click the `Connect` button on the EC2 details page and check the SSH connection command in the SSH Client tab. Then, run the command in your terminal to connect to the EC2 instance, and follow the instructions below to install the packages.

<Steps>
  <Step title="Enter the following command to disable Ubuntu firewall.">
    ```bash theme={null}
    sudo ufw disable
    ```
  </Step>

  <Step title="Install and configure Node.js (nvm)">
    ```bash theme={null}
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
    ```

    ```bash theme={null}
    source ~/.bashrc
    nvm install 16
    nvm alias default 16
    node -v
    ```
  </Step>

  <Step title="Install pm2">
    ```bash theme={null}
    npm install pm2@latest -g
    ```
  </Step>

  <Step title="Install Docker">
    ```bash theme={null}
    sudo apt-get update
    sudo apt-get install ca-certificates curl
    sudo install -m 0755 -d /etc/apt/keyrings
    sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    sudo chmod a+r /etc/apt/keyrings/docker.asc
    ```

    ```bash theme={null}
    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
      $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    ```

    ```bash theme={null}
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    ```
  </Step>

  <Step title="Install Helm">
    ```bash theme={null}
    curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
    ```

    ```bash theme={null}
    chmod 700 get_helm.sh
    ./get_helm.sh  
    ```
  </Step>
</Steps>

## Export Environment Variables

```bash theme={null}
export AWS_ACCESS_KEY_ID=<AWS Access Key>
export AWS_SECRET_ACCESS_KEY=<AWS Secret Access Key>
export AWS_REGION=<AWS Region>
export AWS_HOSTED_ZONE_ID=<Route53 Hosted Zone ID>
export AWS_DOMAIN=<Route53 Domain>
export ACME_EMAIL=<ACME Email>
```

<AccordionGroup>
  <Accordion title="AWS Route53 Hosted Zone ID">
    <Frame>
      <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/aws-terraform/images/05_01.png" />
    </Frame>

    > You can find the **Hosted Zone ID** in **Route53 > Hosted Zones > Hosted Zone Details**.
  </Accordion>
</AccordionGroup>
