| new skills - Team Nuggets
New Training: Use PowerShell Requirements to Remediate EC2 Instances in Amazon Web Services
In this 6-video skill, CBT Nuggets trainer Trevor Sullivan explores how to perform automated AWS remediation with the PowerShell Requirements module. Watch this new DevOps training.
Learn DevOps with one of these courses:
- AWS Cloud Automation with Powershell
- AWS Cloud Automation
This training includes:
- 6 videos
- 58 minutes of training
You’ll learn these topics in this skill:
- Introduction to Requirements Module and AWS Remediation
- Configure Automation Environment for Requirements Testing
- Create a Simple Requirement to Test Amazon EC2 Instance Type
- Auto-Remediate Non-compliant EC2 Instance by Removal or Resizing
- Dynamically Apply PowerShell Requirements to All EC2 Instances
- Formatting Output of Requirements Validation Steps
How to Use PowerShell to Ensure EC2 Instances Meet Business Requirements
PowerShell is one of the best command-line environments for working with AWS resources — and that's due to how PowerShell handles data. PowerShell is capable of handling data as objects instead of generic strings, which are all but required to work with the AWS SDK. That means that PowerShell can also be used to remediate issues with AWS EC2 instances.
For example, let's say that your business requires all EC2 instances to have the same attributes. There's historically been an issue in your organization where various cloud developers weren't sure of the business requirements, so various EC2 instances were created with different parameters. A PowerShell script could be made to cycle through each instance, check their settings, and if they aren't correct, apply the correct parameters.
This isn't hard to accomplish. First, PowerShell would need to get a list of the EC2 instances by using the Get-EC2Instance cmdlet piped with the Select-Object InstanceID parameter. That will list EC2 Instances along with their instance ID. That data can then be thrown into an array.
After that array is created, a loop can be called that cycles through each EC2 instance using that same Get-EC2Instance command but with the -InstanceID flag this time. That command will pull the information for a single specific EC2 instance.
Once the detailed information for an individual EC2 instance is pulled from AWS, it can be compared against business standards. If that EC2 instance doesn't meet business standards, the Edit-EC2InstanceAttribute can be used to correct it.
Of course, this is only one example of how PowerShell can be used to remediate issues with AWS resources.