This project aims to deploy the game 2048 contained in a Dockerfile on Elastic Beanstalk using Terraform (but you can use it with any containerized app). Elastic Beanstalk is an AWS-managed application orchestration service that simplifies the deployment, scaling, and management of your applications.
Before getting started, make sure you have the following configured:
- An AWS account with access keys and permissions to deploy resources.
- Terraform installed locally on your development machine.
- AWS CLI in order to configure credentials.
- Your Docker application's file (Dockerfile, docker-compose.yml or Dockerrun.aws.json) containing all the dependencies and configurations required for running the application.
Make sure you have correctly configured AWS credentials on your machine.
aws configure
- Clone this repository to your local machine.
- Navigate to the project directory.
- Place your application's file at the root of the project.
.
├── Dockerfile
├── README.md
├── eb.tf
├── outputs.tf
├── provider.tf
├── random_pet.tf
├── s3.tf
├── terraform.tfvars
└── variables.tf
- Ensure all necessary configurations have been made in the Docker application file.
- Open a terminal and navigate to the root directory of the project.
- Run the command
terraform init
to initialize Terraform and download the required providers. - Run the command
terraform apply
to create the resources on AWS. - Once the deployment is complete, you'll receive the access URL (CNAME) for your Elastic Beanstalk application in the terminal.
Outputs:
env_cname = "http://2048-game.eba-gbpzfpec.us-east-1.elasticbeanstalk.com"
The deployment process involves the following steps:
- Terraform will create an Elastic Beanstalk instance based on the provided Docker application file.
- Elastic Beanstalk will push the Docker image onto the instance and deploy the application.
- You'll be able to access your application using the URL provided by Elastic Beanstalk.
To avoid unnecessary charges, make sure to run terraform destroy
in order to destroy the created resources after finishing your tests.
The code for the 2048 game in this project is based on the work of gabrielecirulli.