Skip to content

Instantly share code, notes, and snippets.

@phobologic
Created December 19, 2017 00:26
Show Gist options
  • Save phobologic/39e2916eed489cba10f7c7523fe63fe4 to your computer and use it in GitHub Desktop.
Save phobologic/39e2916eed489cba10f7c7523fe63fe4 to your computer and use it in GitHub Desktop.
from troposphere import Template
from troposphere.ec2 import (
SecurityGroup,
SecurityGroupIngress,
)
t = Template()
sg1 = t.add_resource(
SecurityGroup(
"SecurityGroup1",
GroupDescription="Security Group 1",
)
)
sg2 = t.add_resource(
SecurityGroup(
"SecurityGroup2",
GroupDescription="Security Group 2",
)
)
rule = t.add_resource(
SecurityGroupIngress(
"AllowSSHFromGroup1ToGroup2",
FromPort=22,
ToPort=22,
IpProtocol="tcp",
GroupId=sg2.Ref(),
SourceSecurityGroupId=sg1.Ref(),
)
)
print t.to_json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment