In this exercise we will take a fleshed out web server CloudFormation template, and wire it up so that it bootstraps our PowerShell DSC configuration script on the EC2 instances it creates for us
- Discover some of the functionality CloudFormation offers to configure provisioned instances with
- Bootstrap Powershell DSC configuration on created EC2 instances by leveraging cfn-init
- Read through this example of Bootstrapping Windows Instances
- Read the documentation on the CloudFormation::Init template
- Open .\Exercise4\Templates\Webserver.template
- Locate the the WebServerAzOne resource definition within the webserver template
- Follow the Bootstrapping Windows Instances example and fill out the UserData section of the template to kickstart cfn-init
- Complete the sources section of the CloudFormation::Init template within WebServerAzOne to pull down
- Our powershell modules from the PowerShellModulesBundleUrl template parameter to C:\Program Files\WindowsPowerShell\Modules
- Our scripts from the BootstrapperScriptBundleUrl template parameter to c:\cfn\Zephyr\Scripts
- Complete the commands section of the CloudFormation::Init template within WebServerAzOne to
- Set the powershell execution policy to unrestricted
- Invoke our ConfigureWebserver DSC configuration
- Duplicate 5-7 on WebServerAzTwo
- Open .\Exercise4\Parameters.ps1. Update the ResourcePrefix parameter to your initials, and take note of the other parameters provided
- Open Deploy.ps1 locally in Powershell ISE.
- F5!!!
- Open the CloudFormation console in AWS and monitor your stack's creation
- If it fails, troubleshooting time! Pick your troubleshooting buddy and get it sorted
- If it succeeds, open up the EC2 console and remote into one of your instances
- Open c:\cfn\logs\cfn-init.log
- Can you see your DSC output inside it? Are there any errors, or does everything look good?
cfn-init will consider its job done when at the point when all of its commands have succesfully completed - this is going to be at the first reboot of your DSC. This means that if subsequent parts of your DSC fail, the cloud formation init logs are not going to tell you - so you need to monitor your DSC logs to ensure it is happily configured.
- Revisit your recently acquired DSC log analyzing skills. Has everything gone swimmingly?
- Profit!