Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 2.89 KB

Exercise4.md

File metadata and controls

40 lines (31 loc) · 2.89 KB

Exercise 4

Bootstrapping CloudFormation created instances with PowerShell DSC

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

Goals

  • Discover some of the functionality CloudFormation offers to configure provisioned instances with
  • Bootstrap Powershell DSC configuration on created EC2 instances by leveraging cfn-init

Instructions

  1. Read through this example of Bootstrapping Windows Instances
  2. Read the documentation on the CloudFormation::Init template
  3. Open .\Exercise4\Templates\Webserver.template
  4. Locate the the WebServerAzOne resource definition within the webserver template
  5. Follow the Bootstrapping Windows Instances example and fill out the UserData section of the template to kickstart cfn-init
  6. 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
  7. Complete the commands section of the CloudFormation::Init template within WebServerAzOne to
    • Set the powershell execution policy to unrestricted
    • Invoke our ConfigureWebserver DSC configuration
  8. Duplicate 5-7 on WebServerAzTwo
  9. Open .\Exercise4\Parameters.ps1. Update the ResourcePrefix parameter to your initials, and take note of the other parameters provided
  10. Open Deploy.ps1 locally in Powershell ISE.
  11. F5!!!
  12. Open the CloudFormation console in AWS and monitor your stack's creation
  13. If it fails, troubleshooting time! Pick your troubleshooting buddy and get it sorted
  14. If it succeeds, open up the EC2 console and remote into one of your instances
  15. Open c:\cfn\logs\cfn-init.log
  16. Can you see your DSC output inside it? Are there any errors, or does everything look good?

Gotcha

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.

  1. Revisit your recently acquired DSC log analyzing skills. Has everything gone swimmingly?
  2. Profit!