In this section, we will proceed to create an Application Stack based on the Base Infrastructure from the previous section, the resources will include the following:
Application Load Balancer
Launch Template and Auto Scaling Group
IAM Role for EC2 instances to be managed by Systems Manager
If we manually create these resources, the total time will be quite long and we cannot achieve the goal we set regarding automation. To save time as well as automate the initialization process, the CloudFormation Stack needs to be deployed as follows.
CloudFormation Stack
To proceed with infrastructure deployment, we will use the AWS CloudFormation service via the AWS Console or AWS CLI.
Component
Value (Required)
Stack Name
pattern3-app
Template
pattern3-application.yml - download in the Template section below
Wait for the Stack to complete creation. This process takes about 5 to 10 minutes because CloudFormation has to wait for the cfn-signal from EC2 instances.
Thanks to this, initially you don’t need to know what the AMI ID is, and in the automation part, the new AMI will override the default value. You can check the latest Amazon Linux 2023 AMI in the Region using the following command:
Once the CloudFormation Stack is created successfully, we will proceed to verify whether the application has been deployed properly or not.
From the CloudFormation Stack Outputs, find the value of OutputPattern3ALBDNSName.
Try accessing it on a web browser and check if the result has the title Welcome to FCAJ - AWS Study Group - Autonomous Patching Workshop.
At the URL path on the web browser, let’s append the following path - /details.php.
Check if the result is a list of installed software. Please save the displayed data, including Operating System, Amazon Image Id, and the number of Installed Packages. We will cross-reference these values after the automated patching process finishes in section 5.
After the Stack is in CREATE_COMPLETE status and the details.php page displays correctly, we transition to the next section with the AMI Builder Pipeline.