Created
December 19, 2017 00:26
-
-
Save phobologic/39e2916eed489cba10f7c7523fe63fe4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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