Deploying to the cloud is hard. Here are some tips, focused on AWS.
There are loads of ways to deploy an application to AWS. If you want to avoid lock-in, though, you probably want to containerize your application. You can read more about the benefits of containers here. We also find it particularly useful to use Compose files to define how your application should run alongside other services like databases, caches, object storage, etc.
Okay. So now that we've containerized our application. How do we run it on AWS? AWS offers many ways to run containers, but we'll focus on three of the most common ways: a single EC2 instance, ECS, and EKS.
Prerequisites: You'll need an AWS account and the AWS CLI
In each of these cases, it's probably a good idea to have the AWS CLI installed. You can find instructions on how to do that here and here.
Single EC2 Instance. Simple, but not production ready.
The simplest way to run a container on AWS is to create an EC2 instance (a Virtual Machine) and run your container on it. This is fine for development and testing, but not great for production-ready apps: if your instance goes down, your application goes down, and you cannot scale your application easily if your traffic increases.
To deploy a container with EC2 you'll need to use an AMI like this one from Docker. You'll also need to do things like pull your code manually and rebuild/run when you have any updates. Or you can run builds in a CD pipeline, push those to a registry like ECR, and then pull those images onto your instance and restart your Compose project.
ECS. Great for most apps.
Amazon ECS is a managed container orchestration service from AWS. It's great for most applications. You can run your containers across multiple instances, and ECS will allow you to do things like horizontal scaling, rolling updates, and more to keep your application running smoothly as you grow.
To get started with ECS, you'll need to create a cluster and a task definition that describes how your containers should run. You'll also need to create a service that tells ECS how many copies of your task to run and how to load balance traffic across them.
Similarly to the EC2 instance, you'll also need to build your images somehow, probably using a CD pipeline, push those to a registry like ECR, and then update your service to use the new image.
Kubernetes (EKS). When you have a DevOps team.
Amazon EKS is a managed Kubernetes service from AWS. It's great if you have a DevOps team that is already familiar with Kubernetes and if you have more complex requirements. It also allows you to take advantage of the extensive library of Helm charts that are available. Kubernetes is very powerful, but it's also very complex, and it can be difficult to manage. EKS is a lot more expensive than ECS too, so you should only use it if you need the extra capabilities.
To get started with EKS, you'll need to create a cluster and a deployment that describes how your containers should run. You'll also need to create a service that tells Kubernetes how to load balance traffic across your containers.
Similarly to ECS, you'll also need to build your images somehow, probably using a CD pipeline, push those to a registry like ECR, and then update your deployment to use the new image.