#NEWLINE# @ mock_cloudformation #NEWLINE# @ mock_ec2 #NEWLINE# def test_multiple_security_group_ingress_separate_from_security_group_by_id( ) : #NEWLINE# #INDENT# template = { #NEWLINE# #INDENT# 'AWSTemplateFormatVersion' : '2010-09-09' , #NEWLINE# 'Resources' : { #NEWLINE# #INDENT# 'test-security-group1' : { #NEWLINE# #INDENT# 'Type' : 'AWS::EC2::SecurityGroup' , #NEWLINE# 'Properties' : { #NEWLINE# #INDENT# 'GroupDescription' : 'test security group' , #NEWLINE# 'Tags' : [ { #NEWLINE# #INDENT# 'Key' : 'sg-name' , #NEWLINE# 'Value' : 'sg1' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'test-security-group2' : { #NEWLINE# #INDENT# 'Type' : 'AWS::EC2::SecurityGroup' , #NEWLINE# 'Properties' : { #NEWLINE# #INDENT# 'GroupDescription' : 'test security group' , #NEWLINE# 'Tags' : [ { #NEWLINE# #INDENT# 'Key' : 'sg-name' , #NEWLINE# 'Value' : 'sg2' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# 'test-sg-ingress' : { #NEWLINE# #INDENT# 'Type' : 'AWS::EC2::SecurityGroupIngress' , #NEWLINE# 'Properties' : { #NEWLINE# #INDENT# 'GroupId' : { #NEWLINE# #INDENT# 'Ref' : 'test-security-group1' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'IpProtocol' : 'tcp' , #NEWLINE# 'FromPort' : '80' , #NEWLINE# 'ToPort' : '8080' , #NEWLINE# 'SourceSecurityGroupId' : { #NEWLINE# #INDENT# 'Ref' : 'test-security-group2' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# template_json = json . dumps ( template ) #NEWLINE# cf_conn = boto . cloudformation . connect_to_region ( 'us-west-1' ) #NEWLINE# cf_conn . create_stack ( 'test_stack' , template_body = template_json ) #NEWLINE# ec2_conn = boto . ec2 . connect_to_region ( 'us-west-1' ) #NEWLINE# security_group1 = ec2_conn . get_all_security_groups ( filters = { #NEWLINE# #INDENT# 'tag:sg-name' : 'sg1' , #NEWLINE# #UNINDENT# } ) [ 0 ] #NEWLINE# security_group2 = ec2_conn . get_all_security_groups ( filters = { #NEWLINE# #INDENT# 'tag:sg-name' : 'sg2' , #NEWLINE# #UNINDENT# } ) [ 0 ] #NEWLINE# security_group1 . rules . should . have . length_of ( 1 ) #NEWLINE# security_group1 . rules [ 0 ] . grants . should . have . length_of ( 1 ) #NEWLINE# security_group1 . rules [ 0 ] . grants [ 0 ] . group_id . should . equal ( security_group2 . id ) #NEWLINE# security_group1 . rules [ 0 ] . ip_protocol . should . equal ( 'tcp' ) #NEWLINE# security_group1 . rules [ 0 ] . from_port . should . equal ( '80' ) #NEWLINE# security_group1 . rules [ 0 ] . to_port . should . equal ( '8080' )