> ## 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 ALB Setup

## Create Target Group

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

> Click `Create target group` in `EC2 > Load Balancing > Target groups`.

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

> In the Specify group details menu, enter or select the target group information as follows and click `Next`.

* Basic configuration
  * Choose a target type: Instances
  * Target group name: Enter target group name
  * Protocol-Port: HTTP, 9001
  * IP address type: IPv4
  * VPC: Select VPC containing the instance
  * Protocol version: HTTP1

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

> Select the instance where `ale` is installed, enter 9001 in Ports for the selected instances, and click Include as pending below.
> Then click `Create target group`.

## Create ALB

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

> Click `Create Load Balancer` in `EC2 > Load Balancing > Load balancers`.
> Then select **Application Load Balancer**.

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

> Enter or select the load balancer information as follows and click `Create load balancer`:

* Basic configuration
  * Name: ALB name
  * Scheme: internet-facing
  * IP address type: ipv4
* Network mapping
  * VPC: Select VPC containing the instance
  * Availability Zones: Select all available subnets
* Security groups
  * Security groups: Select security group applied to EC2 instance
* Listeners and routing
  * Listener port: 80
  * Target group: Select previously created target group

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

> Click `Add rule` in the created Load balancer page, and create a rule following these 5 steps:

<Steps>
  <Step title="Add rule">
    <Frame>
      <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/04_07.png" />
    </Frame>

    > Enter the Rule name in the Name field.
  </Step>

  <Step title="Define rule conditions">
    <Frame>
      <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/04_08.png" />
    </Frame>

    > Click `Add condition`, select Host header in the modal, enter `app.[domain]`, and click `confirm` to create a Condition card. Then click `Next`.
  </Step>

  <Step title="Define rule Actions">
    <Frame>
      <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/04_09.png" />
    </Frame>

    > Select Forward to target groups for Action types, choose the previously created target group, and click `Next`.
  </Step>

  <Step title="Set rule priority">
    <Frame>
      <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/04_10.png" />
    </Frame>

    > Set Priority to 1 and click `Next`.
  </Step>

  <Step title="Review and create">
    <Frame>
      <img className="block rounded-md" src="https://files.cloudtype.io/ale-docs/setup/ec2/images/04_11.png" />
    </Frame>

    > Finally, click `Create` to create the rule.
  </Step>
</Steps>

<Note>
  After creating the rule, wait a moment. If `ale` is running properly on the instance, the status of the target group routed by ALB will show as Healthy as in the image below.

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

## Create DNS Record for ale dashboard

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

> Click `Create record` in Route53 > Hosted zones > Target domain page.

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

> Enter the values as follows in the create record page and click `Create record`:

* **Record name**: app
* **Record type**: A
* **Alias**: Enable
* **Route traffic to**
  * **Alias to Application and Classic Load Balancer**
  * **Region**: VPC region
  * **ALB**: Select previously created ALB

<Info>
  The domain with the configured record name (e.g., app.aletest.run) will be used as the access domain for `ale`.
</Info>

## Request ACM Certificate

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

> Click `Request` in the AWS Certificate Manager dashboard, select Request a public certificate on the following screen, and click `Next`.

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

> Enter the certificate information as follows and click `Request`:

* Domain names
  * Fully qualified domain name: app.\[domain]
* Validation method
  * DNS validation
* Key configuration
  * RSA 2048

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

> For DNS validation, click `Create record in Route 53` on the created certificate page, then click `Create records`.

## Add HTTPS Listener to ALB

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

> Click `Add listener` on the created Load balancer page in `EC2 > Load Balancing > Load Balancers`.

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

> Enter the values as follows on the next screen and click `Add`:

* Listener configuration
  * Protocol: HTTPS
  * Port: 443
* Default actions
  * Routing actions: Forward to target groups
    * Target group: Select previously created target group
* Security Policy
  * Security category: All security policies
  * Policy name: Apply policy marked as `recommended`
* Default SSL/TLS server certificate
  * Certificate source: From ACM
  * Certificate: Select previously created ACM certificate

<Tip>
  Test that you can access `ale` by visiting `https://app.[domain]`.

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

<Note>
  Ingress configuration is required for operation.
</Note>
