How to Deploy an Appwrite Backend on AWS for FREE
Tags: appwrite, microtica, aws, kubernetes
Published: 2023-04-19 11:50:50


[Appwrite](https://appwrite.io/) is an open-source backend server that helps developers build scalable and secure applications quickly. With Appwrite, developers can easily add authentication, file storage, and database capabilities to their applications, without having to write any backend code. In this article, we will guide you on how to deploy Appwrite on AWS using Microtica.

Microtica is a self-service cloud delivery platform that simplifies the deployment and management of applications on AWS. With Microtica, developers and DevOps engineers can easily set up infrastructure, CI/CD pipelines, deploy applications to AWS and manage their infrastructure with ease.

## Why self-host Appwrite on AWS?

Deploying Appwrite on AWS, with Microtica’s template, provides several benefits, including:

* Out-of-the-box container infrastructure based on Kubernetes, application load balancer, and persistent storage

* Provisioning on your AWS account for infrastructure and data ownership

* Autoscaling based on application load

* Automated git-push deployments and rollbacks

* Resource monitoring and performance insights in-app

* Cloud Cost Optimization

## Prerequisites

* A Git account. Any provider from GitHub, BitBucket, GitLab, and CodeCommit is supported.

* Create a [Microtica account](https://app.microtica.com/auth/signup?utm_source=devto&utm_medium=blog&utm_campaign=appwrite) by signing up with your email or Git account.

* You need to have an AWS account to be able to deploy apps to the cloud with Microtica. Here you can [sign up for an AWS account](https://aws.amazon.com/).

## Deploy a new Appwrite Backend Server

After creating a Microtica account, click the ***Deploy app*** button to land on the Templates page, where you can see a list of all production-ready templates.

[![One-click button](https://cdn-images-1.medium.com/max/2160/0*Qd95y_hcjtDDyB0e)](https://app.microtica.com/templates/new?template=https%3A%2F%2Fraw.githubusercontent.com%2Fmicrotica%2Ftemplates%2Fmaster%2Fappwrite%2F.microtica%2Ftemplate.yaml&utm_source=devto&utm_medium=blog&utm_campaign=appwrite#_ga=2.208929042.1441943728.1681807216-970319415.1625847972)

This template creates the following infrastructure resources that will be provisioned on your AWS account:

* VPC, subnets and networking,

* EKS Cluster — Container infrastructure based on Kubernetes, application load balancer and persistent storage

## 1. Create a Git repository

After connecting your preferred Git account in Microtica, the platform will generate a repository on your Git account using the default repository name of `appwrite`.

![Create a Git repository](https://cdn-images-1.medium.com/max/2392/0*R0JMKSebZffLXxqN)

## 2. Configure Template

Here you can customize the template for your needs by providing environment variables. Enter an application name and the database password that will be used as the MariaDB password. The same password will be used as a token for the Appwrite Executor.

![Configure Template](https://cdn-images-1.medium.com/max/2500/0*k2beQdLYbAGPLTG-)

Environment variables can be updated/added/configured after deployment as well.

## 3. Deployment Destination

In the last step, you can choose the Kubernetes cluster where your Appwrite backend will deploy. Deploying on your AWS account means you need to create an AWS-managed Kubernetes (EKS) cluster, and you can start that process by clicking on the ***Create Amazon EKS Cluster*** button.

Here you can select the environment in which you want to deploy the template. An existing default environment called `development` will be available here, or you can create a new environment if you’d like.

![Deployment Destination](https://cdn-images-1.medium.com/max/2370/0*Ese9LzsO0RBV9rtE)

After selecting an environment, you need to select an AWS account and region where the EKS cluster will be deployed. If you haven’t connected an AWS account yet, you can do it right here by clicking the ***Connect AWS Account*** button. This will initiate a CloudFormation stack that will give Microtica permissions to provision infrastructure on your AWS account.

Once you create the stack, the connection will be established automatically and you’ll be able to see the AWS account in the dropdown list of accounts.

Select the account, select a region, and then click on ***Continue*** to move to the deployment of your environment.

## 4. Deploy the Appwrite Server template to AWS

Finally, a deployment summary of what will be provisioned on your AWS account is presented.

![Deploy the Appwrite Server template to AWS](https://cdn-images-1.medium.com/max/2362/0*8c9Bsvy1pMTtiC-x)

Clicking the ***Deploy ***button will trigger a deployment of the template and start creating the infrastructure (the EKS cluster) for an Appwrite Backend.

It will take around 15 min for the solution to be deployed on a new Kubernetes cluster. You can follow the build pipeline in real time by clicking the ***View Logs*** button.

Once the build process is complete, a new deployment with the infrastructure resources is triggered. You can follow the logs of the deployment process by clicking the ***View deployment*** button, and then selecting the deployment from the list.

![Follow the logs of the deployment process](https://cdn-images-1.medium.com/max/2436/0*8tR4VKoLGvT2Rwh9)

When the deployment of a new EKS cluster is finished, click the ***View logs*** button to follow the deployment process of the Appwrite application.

## Access the Appwrite backend

Once the deployment of the application is finished, click the ***View application*** button and you’ll be redirected to the app *Overview* page. Here you can ***Assign a domain*** to your application, to be able to access it later. You can use a Microtica-assigned domain which is free, or setup your own custom domain. Follow the steps to complete the exposure of your Appwrite backend on the Internet.

![Access the Appwrite backend](https://cdn-images-1.medium.com/max/2474/0*xTLDipt7OTJrgYFc)

If you need more information you can find it in [our documentation](https://docs.microtica.com/assign-a-custom-domain?utm_source=devto&utm_medium=blog&utm_campaign=appwrite).

After the deployment for the domain changes to take effect is finished, click on ***Visit*** to preview the application. This is the server URL that you can use to access API endpoints.

## Bonus: Cleanup

To remove all the resources created on your AWS account, navigate to your environment and click the ***Actions*** button on the right — ***Undeploy*** ***Resources***.

![Cleanup](https://cdn-images-1.medium.com/max/2000/0*fh4Qk6J2_YM-YVp-)

This will clean up the resources created in AWS, but you will still have the configuration in Microtica in case you want to deploy it in the cloud again.

## Add Custom Environment Variables

You can follow [our documentation](https://docs.microtica.com/appwrite?utm_source=devto&utm_medium=blog&utm_campaign=appwrite#FfJqZ) to learn how to configure environment variables from Microtica Console.