Overview
Lab details
- This lab will cover the basics of AWS CloudFormation Stack through creating a simple LAMP Server. The motive of this lab is to explore the functionality of an S3 bucket, demonstrate the process of creating a CloudFormation stack using an S3 Object URL, and guide participants through the installation of a PHP sample application.
- Duration: 30 minutes
- AWS Region: US East (N. Virginia) us-east-1
Introduction
LAMP Server
LAMP (Linux, Apache, MySQL, PHP/Perl/Python) is an acronym denoting one of the most common solution stacks for many of the web’s most popular applications. However, LAMP now refers to a generic software stack model and its components are largely interchangeable.AWS CloudFormation
- CloudFormation is a service provided by AWS for designing our own infrastructure using code, i.e. infrastructure as code.
- Currently, CloudFormation supports two languages, JSON and YAML. You can write your code with one of the languages.
- CloudFormation comes with great features, being able to update your infrastructure whenever you want and also having the ability to delete the stack in case you don’t need it.
- A fascinating feature of CloudFormation is that it saves more time in building infrastructure and helps in focusing on the development.
- It is also possible to replicate our infrastructure in a short amount of time.
- It eliminates human error and works according to the code you have written. It consists of two main components, Stack and Templates.
CloudFormation Template
- It consists of various sections like
- AWS Template Format Version
- Description
- Metadata
- Parameters
- Mappings
- Conditions
- Resources (Required Field)
- Outputs
- It is not mandatory that the template requires all the above-mentioned sections. By using only the Resources section, we will be able to create a template.
- The resources section plays an important role in the template creation.
- For example, to create an EC2 instance, a template shall consist of various parameters such as key name, image ID, instance type.
- It is also possible to create two resources in the same template and refer to one from another, i.e. attaching an elastic IP with an EC2 instance.
CloudFormation Stack
- A stack consists of a collection of resources.
- In other words, the stack consists of one or more templates.
- The advantage of the stack is that it is easy to create, delete or update the collection of resources.
- The advanced stacks have a nested stack which holds a collection of stacks.
Architecture diagram

Task details
- Sign in to AWS Management Console.
- Exploring templates in an S3 bucket.
- Create CloudFormation Stack.
- Testing
- Validation of the lab.
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time
Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
- On the AWS sign-in page,
- Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
- Now copy your User Name and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign in button.
- Once Signed In to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.
Task 2 : Exploring templates in an S3 Bucket
- Make sure you are in the US East (N. Virginia) us-east-1 Region.
- Navigate to the services menu in the top, click on S3 in the Storage section.
- You can see the bucket present with a name similar to whizlabs.1400.54051021. In your case, the name of the bucket might be different numerics.
- Open that bucket and you will see LAMP_template.json file.
-
Now copy the Object URL and save it in notepad.

- This given LAMP_template.json contains the JSON code for launching the LAMP Server using Cloudformation.
Task 3 : Create Cloudformation Stack
- Navigate to CloudFormation. Click services, click on CloudFormation in the Management and Governance section.
-
On the CloudFormation dashboard, click on create stack.
- Prerequisite - Prepare template : Select Choose an existing template
-
Specify Template :
- Template source: Select Amazon S3 URL
- Amazon S3 URL: Paste the URL copied from earlier steps.

- Click on Next.
-
Specify stack Details
- Stack name: Enter a unique stack name - MyFirstCFStack
-
Parameters
- DB Name : Enter a database name - MyDatabase
- DB Password : Enter a database password - whizlabsdb123
- DB Root Password : Enter database root password - whizlabsdbroot123
- DB User : Enter the database username - WhizlabsDBUser
- Instance Type : Select t2.micro
- Key Name : Select the key from the list name whizlabs-key
- SSH Location : Enter 0.0.0.0/0
-
Click on Next.


-
Configure stack options :
-
Tags: Click on add new tag
- Key : Enter Name
-
Value : Enter MyCF

- Permissions: No need to select for this lab, leave it blank.
- Leave all other configuration fields as default.
- Click on Next.
-
Tags: Click on add new tag
- Review: Review your stack details and click on Submit.
-
Once you have clicked the create button, you will be redirected to the CloudFormation stack list. A sample screenshot is provided below.

- Status: You will see the status CREATE_IN_PROGRESS.
- You need to wait around 1-5 minutes to complete the stack resource creation.
- Click on the refresh button to see the updates.
- Once your stack status changes to Create Complete.

Task 4 : Testing
- Navigate to the outputs tab and you will be able to see an URL similar to below. Click on the URL. This will take you to your server’s home page.
-
If you see the PHP info and your database connection, it means you have completed a LAMP server setup with AWS CloudFormation. Sample screenshot provided below:

Task 5 : Validation Test
- Once the lab steps are completed, please click on the Check my work button on the right side panel.
- This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
-
Sample output :

Completion and conclusion
- You have successfully created a Lamp server setup using a new Cloudformation Stack with the help of the JSON template provided in the S3 bucket.
- You have successfully tested the new lamp server created by CloudFormation.
End lab
- Sign out from the AWS Management Console.
- Click on End lab button in the IP Lab Portal and wait till the process gets completed.
What gets checked
When you press Check my work, the platform verifies each of these:- Create a CloudFormation Stack — Check whether a CloudFormation stack is created or not.