Skip to content

Instantly share code, notes, and snippets.

@krallin
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krallin/4137f6b06dcc47ab3340 to your computer and use it in GitHub Desktop.
Save krallin/4137f6b06dcc47ab3340 to your computer and use it in GitHub Desktop.
AWS API Sample
import boto.ec2
# Connect to EC2
conn = boto.ec2.connect_to_region("us-east-1") # Credentials are in the environment!
# Create a new SG
security_group = conn.create_security_group("test-sg, "Just making a point!")
# Define SG rules
ip_rules = [("tcp", 80, "0.0.0.0/0"), ("tcp", 443, "0.0.0.0/0")]
# Update the SG with the rules
for protocol, port, network in ip_rules:
security_group.authorize(protocol, port, port, network)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment