iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🍿

Dear AWS, I don't understand the point of apprunner.yaml

に公開
2022/12/23

It's not that I don't understand the AWS App Runner service itself, but rather its configuration file, apprunner.yaml. I want to say, "Isn't a Dockerfile good enough?"

What is AWS App Runner?

In short, it's a service that allows you to easily deploy web applications built with containers. Amazing!
https://aws.amazon.com/jp/apprunner/

AWS App Runner is a fully managed service that makes it easy for developers to quickly deploy containerized web applications and APIs, at scale and with no prior infrastructure experience required.

How to Deploy with AWS App Runner

There are three main ways to deploy with App Runner.

Configure Build and Start Commands in the AWS Console

First. This is the simplest way. You can deploy just by opening the AWS Management Console in your browser and entering a few settings.
Since you can't perform complex operations, it's difficult to use for full-scale product development. However, because it allows you to publish web apps so easily, it's a very useful method for quick trials, learning, or publishing simple personal apps.
I'm linking an article where I tried this method right after App Runner was released.
https://zenn.dev/ibaraki/articles/7b781553eb7a74

Deploy from Amazon ECR

Second. You can deploy from a Docker image on ECR (Elastic Container Registry).
Once you've reached the point of creating an image file and placing it in ECR, you can set up automatic deployment with just a few clicks. This method allows you to create Docker images freely, so it's highly customizable and suitable for production use. However, since you need to build the Docker image and push it to a registry, a basic knowledge of Docker and containers is required. This method is recommended for serious use.

Write Build and Start Command Settings in apprunner.yaml

Third. This is the main point.
I don't understand the use case for this.
I will explain the details in the next chapter.

Why apprunner.yaml is difficult to use

Not much difference from Dockerfile contents

Let's look at the apprunner.yaml sample in the AWS documentation.
https://docs.aws.amazon.com/ja_jp/apprunner/latest/dg/config-file-examples.html

apprunner.yaml
version: 1.0
runtime: python3 
build:
  commands:
    build:
      - pip install pipenv
      - pipenv install 
run: 
  command: python app.py

It seems you write the necessary build commands for creating a Docker image in the build section and the execution command for when the Docker image starts in the run section.

There's nothing wrong with the format itself, but I can't help but think, "Wouldn't a Dockerfile be better for this...?"
Honestly, it's a hassle to learn a new specification when there aren't any groundbreaking features.

Limited environments available

In apprunner.yaml, you cannot specify the OS for the Docker image; it's limited to Amazon Linux. Also, the supported languages are only Python (3.7, 3.8) and Node.js (12).

Isn't that a bit too narrow?

In the console-based approach, the settings are simplified, so it wasn't necessarily a negative. However, when you go to the trouble of writing a configuration file, it's usually because you want to customize things, so this lack of options is disappointing.

Note that these restrictions do not apply when you build App Runner using ECR.

Lack of versatility despite being a container

This is the most difficult point to deal with.

If you search for "container benefits," you'll always find points like "it runs the same way regardless of the environment, whether it's a local development environment or a production environment in the cloud."
Containers are meant to be usable anywhere.

However, when you create a container using apprunner.yaml, it only works on AWS App Runner.
Besides the obvious problems like losing portability and making it harder to set up a development environment, you have to deploy to the cloud every single time just to test the apprunner.yaml itself.
Moreover, App Runner has a mysterious specification where if the initial deployment fails, you can't retry, and the app will never run. In other words, you have to recreate the service as many times as it takes to get it right.

It's incredibly tedious.

I also read other people's articles, but...

I looked at several articles about trying out App Runner, thinking maybe I was using it wrong.

From what I saw, in order of frequency, the cases were:

  • Using ECR
  • Doing it only through the AWS console
  • Using apprunner.yaml and struggling immensely with debugging

That's what I thought. If anyone says, "No, no, you can use apprunner.yaml like this and it's great!", please leave a comment.

By the way, in other AWS services...

When it comes to services that can easily publish web apps on AWS, there's Amplify.
Amplify is often thought to be mainly for SPAs and serverless, but its API functionality supports containers. It reads Dockerfile or docker-compose.yml instead of a unique configuration file and deploys them to ECS.
https://docs.amplify.aws/cli/usage/containers/#deploy-a-single-container

Why did App Runner create its own configuration file...?

Summary

Currently, using apprunner.yaml is not great

When utilizing AWS App Runner, it seems better to avoid using apprunner.yaml and instead use Docker images built by yourself via ECR.

What I want to say to AWS

Wouldn't it be better to use Dockerfile (or docker-compose.yaml or compose.yaml) instead of apprunner.yaml?

Finally

When I looked at the apprunner-roadmap on GitHub, I saw that support for Dockerfile and Docker Compose was requested, so I gave it a 👍.
https://github.com/aws/apprunner-roadmap/issues/26
https://github.com/aws/apprunner-roadmap/issues/32

Discussion