Amazon Linux is an AWS-provided Linux distribution for EC2 virtual machines. Amazon Linux 2 is an optimized distribution used to install web-application software such as Apache, PHP, and WordPress. section 2.1
Keep Amazon Linux 2 updated because vulnerabilities can affect the kernel, libraries, runtime environments, and applications. Critical and important security updates install automatically during startup through cloud-init; additional updates require an explicit strategy. section 5.2
Common update approaches include:
- Run yum -y update in EC2 user data to install all updates during boot. section 5.2
- Run yum -y --security update to install security updates during boot. section 5.2
- Use AWS Systems Manager Patch Manager with a patch baseline and scheduled maintenance windows for continuous patching. section 5.2
Instance:
Type: 'AWS::EC2::Instance'
Properties:
# [...]
UserData: !Base64 |
#!/bin/bash -ex
yum -y update #1
Apply a complete update automatically by placing yum -y update in an EC2 instance's user-data script. section 5.2
Load-balanced WordPress deployment
Run Apache, PHP, and WordPress on at least two EC2 instances using Amazon Linux. An Application Load Balancer distributes traffic, while RDS for MySQL stores database data and EFS shares application files between instances. section 2.1
