In this exercise we will build a cloud formation template to provision the security group and EC2 instance pair that we manually created in Exercise 1
- Gain exposure to AWS powershell API
- Get hands dirty building a CloudFormation template
- Launch a security group and EC2 instance via powershell - Infrastructure as code!
To complete this exercise you'll need to add an appropriate set of credentials to your SDK Credential Store - run ResetCredentials.bat from the repository root with appropriate parameters to do this
- Navigate to .\Exercise2 and open Deploy.ps1 in Powershell ISE
- Spend a some time getting familiar with what it is doing
- How does the template get from our local machine to AWS?
- How do we supply parameters that our CloudFormation template requires?
- Open .\Exercise2\Parameters.ps1. Update the ResourcePrefix parameter to your initials, and take note of the other parameters provided
- Create an empty file named Webserver.template in .\Exercise2\Templates
- Build your template's Skeleton Structure
- Define your Security Group Template
- Refer to the samples available if you need a more complete sample to work from
- Define your EC2 Instance Template
- Kick off .\Deploy.ps1 by F5-ing it in ISE, and open the CloudFormation section of the AWS console
- Monitor your stack's creation by opening the 'Events' tab for a running summary of progress
- If something fails, analyse the error. What went wrong? Double check your template, and the template documentation. Feel free to grab someone to rubber duck!
- If it is all green, jump into the EC2 console and try to remote into your instance
- Great success!
Note: If you installed the Visual Studio Tooling you can use an "AWS CloudFormation project" to work with your template, which will give you some intellisense out of the box.