def add_ip(current_ip, sg_id, port, protocol):
"""Add current IP to the security group"""
# setup client for ec2
client = boto3.client("ec2")
# execute security group ingress Boto3 commands
# TODO: Add in try for graceful error handling
response = client.authorize_security_group_ingress(
GroupId=sg_id,
IpProtocol=protocol,
FromPort=port,
ToPort=port,
CidrIp=current_ip
)
print response
评论列表
文章目录