Advertisement

Thursday, December 5, 2019

AWS : Lambda: Remove IP to Security Group Using Boto3

In this blog I discuss on how to remove an IP from Security Group using Boto3



import boto3
ec2 = boto3.resource('ec2')
s_group = ec2.SecurityGroup('sg-<ID>')
response = s_group.revoke_ingress(IpProtocol="tcp", CidrIp=strIP, FromPort=22, ToPort=22)
print (response)

Here strIP : IP Range - Example 10.24.25.0/24
From Port and To Port are port Ranges 


With the above you can revoke an IP address rule

2 comments:
Write comments