# Installation AWS ECS

Appmixer can be installed in an AWS account via our public Terraform module.

## Prerequisities

* [AWS account](https://aws.amazon.com/)
* [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
* [Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)
* [Cofigured AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)
* Account in Appmixer Docker registry \[registry.appmixer.com]. This account has been given to you during your sign-up process to the Appmixer Self-Managed package.

## Installation Types

There are two types of installations:

* Default installation
* Custom installation

### Default Installation

This type of installation assumes that you don't have any preferences regarding AWS Networking (VPC) and want leave all attributes in default. This kind of installation will create a new VPC and all required network parts (Internet Gateway, NAT Gateway, subnets, route tables, etc.). Then it will provision all the four required AWS managed services:

* Amazon DocumentDB (MongoDB)
* ElastiCache (Redis)
* Opensearch (Elasticsearch)
* Amazon MQ (RabbitMQ)

Next, it will provision AWS ECS (Elastic Container Service) with all Appmixer applications (Engine, Frontend, Backoffice, Quota and Logstash).

### Custom Installation

By configuring **external**\_\* values, you have a choice where to install the Appmixer stack and choose external services like:

* **external\_vpc**: your specific VPC
* **external\_redis**: external Redis (running either in AWS or somewhere else)
* **external\_rabbitmq**: external RabbitMQ (running either in AWS or somewhere else)
* **external\_elasticsearch**: external Elasticsearch (running either in AWS or somewhere else)
* **external\_documentdb**: external MongoDB (running either in AWS or somewhere else)

## Preparation

First, clone the [Appmixer Module AWS](https://github.com/clientIO/appmixer-module-aws) git project with the Terraform code:&#x20;

```bash
$ git clone https://github.com/clientIO/appmixer-module-aws.git
$ cd appmixer-module-aws/
```

This repository contains examples for both dev and production use cases. Also, both of these examples include autoscaling configuration. Let's start with **dev** example:

```bash
$ cd examples/development
```

This example defines a new VPC and it's CIDR block. You will need to configure:

* **zone\_id** (line #44) -> if set AWS Route53 will be used and you should also update **aws\_route53\_zone** (line #33) and set the domain name to be used.
* **ecs\_autoscaling\_config** (line #52) -> Docker registry credentials, base64 encoded string.
* **input\_init\_user** (line #54) -> here you can configure credentials for the initial user (Appmixer admin).

## Installation

You should now be ready to provision the Appmixer stack.

<pre class="language-bash"><code class="lang-bash"><strong>$ terraform init
</strong>$ terraform plan
</code></pre>

In the ouptput of the above commands, you can see the exact resources that will be provisioned. If the output looks right we can proceed:

```bash
$ terraform apply
```

Again, you'll have a chance to check what exactly will be provisioned. If it looks correct, you can approve. After the Terraform run, you'll get the so called Terraform output, where you can find a lot of useful information like Loadbalancer name, service URLs, managed services, etc.
