Deploying Multi-Container Applications to AWS Elastic Beanstalk

The easiest way to deploy containerised applications to AWS is to use Elastic Beanstalk. Instead of creating and managing individual resources (such as EC2, security groups, load balancer, RDS and so on) to run applications, it creates and manage them as environments.

If you want to deploy containers to AWS quickly without learning too much about more granular services like ECS or load balancer, Elastic Beanstalk is the way to go.

To deploy application to Elastic Beanstalk, AWS has a wonderful CLI tool, EB CLI. With a few commands, we can easily deploy an application to Elastic Beanstalk.

As an example, we will use wiremock container. Wiremock is a open-source tools to create API mocks. For the details about how wiremock container works, you can refer to the github repo I created for this post here.

First of all, we need to create a Dockerrun.aws.json file in the project folder. This file is similar to the docker-compose file. It is specifically used for Elastic Beanstalk. It is much simpler than the config files for ECS. When we do multi-container deployment, Beanstalk uses ECS and docker-intalled EC2 as an underlining infrastructure. But, the complexity to manage it is abstracted.

For the container application, the asset is pushed to /var/app/current folder. In the example below, we are mapping the relevant folders that contains data files to the container.

Elastic Beanstalk uses the health check on port 80 from the load balancer by default. So, the first container is mapped to port 80. If you need to use https, the best option is to use route 53 to map DNS to the load balancer created in the environment.

Once we have Dockerrun.aws.json, the rest is easy. First, we initialise the application. Then follow the prompt to choose the options. Make sure to choose multi-container option.

eb init

Now it is ready to go. Just create the environment. Environment in Elastic Beanstalk means application plus all the associated resources. Once we set the name for the environment, the rest will be taken care by the EB CLI.

eb create swapi-mock

After a few minutes, you will have your containers running in AWS.

For updating the code, we can run deploy command.

eb deploy awapi-mock

When you finish it, you can delete the environment. This will terminate all the resources created for the environment.

eb terminate

That’s it. Pretty simple. For further information, you can check the git repo made for this post: deploy-wiremock-container-aws-elastic-beanstalk.

Git
How to specify which Node version to use in Github Actions

When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2. The alternative way is to use a node container. When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not …

AWS
Using semantic-release with AWS CodePipeline and CodeBuild

Here is the usual pattern of getting the source from a git repository in AWS CodePipeline. In the pipeline, we use AWS CodeStart to connect to a repo and get the source. Then, we pass it to the other stages, like deploy or publish. For some unknown reasons, CodePipeline downloads …

DBA
mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

mysqldump 8 enabled a new flag called columm-statistics by default. When you have MySQL client above 8 and try to run mysqldump on older MySQL versions, you will get the error below. mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM ‘$”number-of-buckets-specified”‘) FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = ‘myschema’ AND TABLE_NAME = ‘craue_config_setting’;’: Unknown …