“CloudFormation gives you the ability to let your creative juices flow in the world of automation”
A few blog posts back, I wrote 2 articles on creating an AWS EC2 Linux instance followed by creating an AWS EC2 Windows instance.
Within those two tutorials, not only did I step through and explain all the settings within the creation wizard, but I also provided a user-data script that would automate the installation and configuration of the webserver components.
All up, this took a few minutes per EC2 instance to create.
Fast forward to today, where I show you how to use AWS CloudFormation to automate the installation of EC2 instances.
Provisioning EC2 instances via CloudFormation takes me around 1 minute 15 seconds. So this is a huge time saver compared to using the EC2 setup wizard.
Not only do you save time, but most importantly you save your sanity by not having to repeat the same process over and over again. In other words, imagine having to deploy 10 front-end webservers, it would be a nightmare creating each one of those manually.
Therefore, how about we write this all up in a YAML file, create a stack within CloudFormation and automate the whole process ?
AWS CloudFormation Tutorial
Within the tutorial below, we look at creating a CloudFormation stack using a pre-prepared YAML file.
Firstly, I will go ahead and create an EC2 Linux instance. This includes:
- attaching a security group allowing port 80
- performing a yum update
- setup of the httpd webserver with an index.html landing page.
Within the landing page, I populate EC2 metadata by querying http://169.254.169.254/latest/meta-data URLs
Secondly, I go ahead and use a new CloudFormation stack to create a Windows 2019 webserver. This demo will use PowerShell to set up the IIS web server component. The stack will also populate an index.html file with EC2 meta-data.
Lastly, we browse the public address of our web server which displays a simple HTML file as you can see below:
Both YAML files are provided to you via my GitHub page. The links are provided within the Youtube video description below.
Be the first to comment