AWS code-library documentation change
Summary
Added PowerShell V5 examples for StartInstances including DryRun validation
Security assessment
Demonstrates DryRun parameter usage for permission checks, a security best practice, but not tied to a specific vulnerability fix.
Diff
diff --git a/code-library/latest/ug/ec2_example_ec2_StartInstances_section.md b/code-library/latest/ug/ec2_example_ec2_StartInstances_section.md index e8cea7c90..3d091397d 100644 --- a//code-library/latest/ug/ec2_example_ec2_StartInstances_section.md +++ b//code-library/latest/ug/ec2_example_ec2_StartInstances_section.md @@ -515,0 +516,49 @@ PowerShell +**Tools for PowerShell V5** + + +**Example 1: This example starts the specified instance.** + + + Start-EC2Instance -InstanceId i-12345678 + + +**Output:** + + + CurrentState InstanceId PreviousState + ------------ ---------- ------------- + Amazon.EC2.Model.InstanceState i-12345678 Amazon.EC2.Model.InstanceState + +**Example 2: This example starts the specified instances.** + + + @("i-12345678", "i-76543210") | Start-EC2Instance + + +**Example 3: This example starts the set of instances that are currently stopped. The Instance objects returned by Get-EC2Instance are piped to Start-EC2Instance. The syntax used by this example requires PowerShell version 3 or higher.** + + + (Get-EC2Instance -Filter @{ Name="instance-state-name"; Values="stopped"}).Instances | Start-EC2Instance + + +**Example 4: With PowerShell version 2, you must use New-Object to create the filter for the Filter parameter.** + + + $filter = New-Object Amazon.EC2.Model.Filter + $filter.Name = "instance-state-name" + $filter.Values = "stopped" + + (Get-EC2Instance -Filter $filter).Instances | Start-EC2Instance + + +**Example 5: This example validates permissions for starting an EC2 instance using the DryRun parameter without actually starting the instance. Note: This throws an exception if succeeded which is the expected behavior.** + + + Start-EC2Instance -InstanceId 'i-0abcdef123456' -Region 'us-west-1' -DryRun $true + + + * For API details, see [StartInstances](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. + + + +