AWS code-library documentation change
Summary
Added PowerShell V5 examples for revoking security group ingress rules
Security assessment
The examples show how to remove network access permissions which is security-related, but there's no evidence of addressing a specific security incident
Diff
diff --git a/code-library/latest/ug/ec2_example_ec2_RevokeSecurityGroupIngress_section.md b/code-library/latest/ug/ec2_example_ec2_RevokeSecurityGroupIngress_section.md index d8e3b98c6..6b428daf2 100644 --- a//code-library/latest/ug/ec2_example_ec2_RevokeSecurityGroupIngress_section.md +++ b//code-library/latest/ug/ec2_example_ec2_RevokeSecurityGroupIngress_section.md @@ -101,0 +102,47 @@ PowerShell +**Tools for PowerShell V5** + + +**Example 1: This example revokes access to TCP port 22 from the specified address range for the specified security group for EC2-VPC. Note that you must identify security groups for EC2-VPC using the security group ID not the security group name. The syntax used by this example requires PowerShell version 3 or higher.** + + + $ip = @{ IpProtocol="tcp"; FromPort="22"; ToPort="22"; IpRanges="203.0.113.0/24" } + Revoke-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission $ip + + +**Example 2: With PowerShell version 2, you must use New-Object to create the IpPermission object.** + + + $ip = New-Object Amazon.EC2.Model.IpPermission + $ip.IpProtocol = "tcp" + $ip.FromPort = 22 + $ip.ToPort = 22 + $ip.IpRanges.Add("203.0.113.0/24") + + Revoke-EC2SecurityGroupIngress -GroupId sg-12345678 -IpPermission $ip + + +**Example 3: This example revokes access to TCP port 22 from the specified address range for the specified security group for EC2-Classic. The syntax used by this example requires PowerShell version 3 or higher.** + + + $ip = @{ IpProtocol="tcp"; FromPort="22"; ToPort="22"; IpRanges="203.0.113.0/24" } + + Revoke-EC2SecurityGroupIngress -GroupName "my-security-group" -IpPermission $ip + + +**Example 4: With PowerShell version 2, you must use New-Object to create the IpPermission object.** + + + $ip = New-Object Amazon.EC2.Model.IpPermission + $ip.IpProtocol = "tcp" + $ip.FromPort = 22 + $ip.ToPort = 22 + $ip.IpRanges.Add("203.0.113.0/24") + + Revoke-EC2SecurityGroupIngress -GroupName "my-security-group" -IpPermission $ip + + + * For API details, see [RevokeSecurityGroupIngress](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. + + + +