iTranslated by AI
AWS Architecture for Beginners (Web Applications and Computing)
Introduction
Good morning, I'm Kato. As of January 5, 2022, there are 223 services in AWS. There are over a dozen services just in the computing category, and engineers building web applications on AWS must select services and determine the architecture based on requirements.
While making it simply work is one thing, designing an architecture that meets high standards for agility, scalability, and cost-performance requires the presence of a specialist. If there is no specialist within the project team, many companies provide AWS consulting services, so it can be solved through outsourcing. (Of course, we also provide AWS Consulting Services; please feel free to contact us!)
However, there are times when outsourcing is not possible due to cost, schedule, or organizational reasons, or when you want to try it yourself to accumulate know-how. In this article, I will introduce AWS architecture patterns, including deployment methods, for such AWS beginners. As this is aimed at beginners, I have considered the architectures while weighting the learning costs for building, operating, and continuously improving them.
The title includes "Web Application/Computing Edition" to specify the scope, but I do not have plans for a sequel.
Architecture Patterns
For beginners, I believe it is best to consider services in the following order: Amplify Console (for static websites) → App Runner → ECS/Fargate → EC2.
Architecture for Static Websites with Amplify Console
For static websites (recent trends like React, Vue, Next.js, Nuxt.js, etc.), Amplify Console is recommended. It provides useful features for operating static websites out of the box.
- Static website hosting
- CI/CD pipeline
- CDN cache invalidation
- Basic authentication
- Pull Request environment construction
- Response header customization
I recommend creating the Amplify Console setup through the Management Console without defining it as code[1], while including the CI/CD pipeline definition (amplify.yml) in the Git repository. Amplify Console has a feature to provide Server-Side Rendering (SSR) exclusively for Next.js, but since the version dependencies are strict, I recommend using App Runner (described later) if you want to perform SSR.

Please note that it cannot be used for backend purposes.[2]
Since it has a feature to create an environment for each pull request, even when adopting GitHub Flow as a branch strategy, it is great to be able to review while checking the behavior of the actually deployed version.
For more details on Amplify Console, please refer to the following blog.
AWS Amplify Console for Frontend Engineers | DevelopersIO
Architecture for General-Purpose Web Applications with App Runner
App Runner is a computing service specialized for web applications. It provides scalable computing resources for web applications with minimal configuration. When an image is pushed to ECR (the container repository provided by AWS), the application can be updated automatically (manual updates are also possible).
However, because it transitions to an inactive state when not processing synchronous HTTP requests, it does not support batch processing, WebSockets, or GraphQL Subscriptions.
Although it is a service executed outside a VPC, by using a VPC connector, you can access resources like RDS/Aurora or ElastiCache through intra-VPC communication. When using a connector, outbound communication originating from App Runner flows from within the VPC, so a NAT Gateway is required if communication with the internet is necessary. (Responses to user requests are processed outside the VPC.) Additionally, a NAT Gateway is required for AWS API calls (such as accessing S3).[3]

In addition to serving as a backend Web API, it can be used as a deployment destination for server-side templating (dynamic HTML generation on the server side using templates) and server-side rendering (SSR).
When using GitHub as a repository, you can easily upload built container images to ECR by using aws-actions/amazon-ecr-login provided by AWS in GitHub Actions. As mentioned earlier, App Runner can trigger application updates upon pushes to ECR.
By enabling automatic updates only for the staging environment and disabling them for the production environment—instead setting a Git commit hash as the container image tag and deploying from the Management Console when ready—you can confirm the actual behavior before deploying to production. Setting tags with commit hashes for the staging environment as well is convenient for verifying the behavior of any specific version.
App Runner also provides a mechanism to build, test, and run applications within the service without using containers, similar to Amplify Console (supported languages are Python, Node.js, and Java). Consider this if you want to reduce the number of AWS resources and simplify management, even at the cost of some operational flexibility.
If you are not used to Infrastructure as Code (IaC), I believe creating App Runner through the Management Console is fine. App Runner provides a scalable environment with only a few configuration items, so management won't break down even when built via the Management Console. Rather, it's better to decide based on the complexity of the resources App Runner connects to. If you're just connecting to RDS/Aurora, it's safe; however, if you need multiple VPC endpoints and ElastiCache, and have to create three environments (development, staging, and production), management will become difficult without code. My feeling is that if it's just RDS/Aurora and two environments (production and staging), you might not need to codify it (provided you are not yet comfortable with coding infrastructure).
Architecture for Linux Applications with ECS/Fargate
If your application cannot be implemented using the methods introduced so far, consider ECS/Fargate. For example, you need to use ECS in the following cases:
- Processing data by pulling it from the outside instead of receiving requests
- Continuing processing asynchronously after returning a response
- Needing to perform periodic batch processing
- Wanting to perform requests between multiple containers within a private network (i.e., not wanting to implement authentication)
Additionally, you can use AWS WAF by setting up CloudFront with WAF applied and configuring App Runner as the origin. However, if the App Runner URL leaks, direct access can occur. While you can force requests through CloudFront by analyzing HTTP headers in the application, the application will still process the request to some extent, so this must be accepted.
Architecture for Linux Applications with EC2
If you have an application that absolutely cannot be realized with ECS/Fargate, use EC2. Even in this case, if you have requirements for scaling or auto-healing, I recommend creating a Golden AMI and using it to set up Auto Scaling.
When migrating applications running on existing virtual machines to AWS, you might consider EC2 because you want to avoid containerization, which is required by the aforementioned architectures. If that application has no plans for continuous functional improvement or is scheduled for retirement in a few years, that decision is valid.
However, if the reason is simply that you don't need the features Docker provides or that the learning curve is steep, please reconsider. Now that the Docker ecosystem has developed this far and information is easily available on the internet and in books, it is very easy to learn. I believe you can achieve better performance by adopting it and "standing on the shoulders of giants" without thinking too deeply about whether Docker is essentially necessary.
Afterword
There are many parts where my explanation is insufficient, but it took a lot of time to write this far, and I felt if I didn't release it now, it might end up as a draft, so I'm releasing it as is, even if it's a bit rough.
-
To codify the GitHub integration for Amplify Console, a GitHub Personal Access Token is required. This requires extra effort, such as creating a bot account, issuing a token with that account, and registering it in AWS Secrets Manager. Therefore, in this article, I recommend creating it through the Management Console. If the frontend repository is independent, I believe this approach is fine, not just for beginners. For monorepo configurations, I think it's easier to implement using CloudFront + S3 with something like AWS CDK, which offers convenient components like S3 Deployment. ↩︎
-
While it might be possible to make it work as a Web API by using Next.js with SSR on Amplify Console, I didn't consider it because one wouldn't typically do that when using AWS instead of Vercel. ↩︎
-
Alternatively, you can handle this by creating a VPC endpoint for the AWS service. Please note that for interface VPC endpoints, you need to set the endpoint in the SDK. AWS PrivateLink for Amazon S3 - Amazon Simple Storage Service ↩︎
Discussion