I'm currently working on a script for deleting aws resources using aws cli and python. As a part of my script, I have to delete the rules of a security group. The approach that I have taken is I execute the describe-security-groups
command and I am able to store the following value in a variable:
[{u'IpProtocol':u'-1',u'PrefixListIds':[],u'IpRanges':[{u'CidrIp':u'0.0.0.0/0'}],u'UserIdGroupPairs':[],u'Ipv6Ranges':[]}]
However, for passing this value to the revoke-security-group-egress
command, I need it in the following form:
[{"IpProtocol":"-1","PrefixListIds":[],"IpRanges":[{"CidrIp":"0.0.0.0/0"}],"UserIdGroupPairs":[],"Ipv6Ranges":[]}]
I'm looking for a way which could be used for other lists with different structures as well.
Or is there another way to delete all the rules of a security group using aws cli and python?
--UPDATE--
I found a way to come close to what I wanted after reading the answer here