#NEWLINE# @ mock_cloudformation #NEWLINE# @ mock_ec2 #NEWLINE# def test_security_group_with_update( ) : #NEWLINE# #INDENT# vpc_conn = boto . vpc . connect_to_region ( 'us-west-1' ) #NEWLINE# vpc1 = vpc_conn . create_vpc ( '10.0.0.0/16' ) #NEWLINE# template = { #NEWLINE# #INDENT# 'AWSTemplateFormatVersion' : '2010-09-09' , #NEWLINE# 'Resources' : { #NEWLINE# #INDENT# 'test-security-group' : { #NEWLINE# #INDENT# 'Type' : 'AWS::EC2::SecurityGroup' , #NEWLINE# 'Properties' : { #NEWLINE# #INDENT# 'GroupDescription' : 'test security group' , #NEWLINE# 'VpcId' : vpc1 . id , #NEWLINE# 'Tags' : [ { #NEWLINE# #INDENT# 'Key' : 'sg-name' , #NEWLINE# 'Value' : 'sg' , #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# security_group = vpc_conn . get_all_security_groups ( filters = { #NEWLINE# #INDENT# 'tag:sg-name' : 'sg' , #NEWLINE# #UNINDENT# } ) [ 0 ] #NEWLINE# security_group . vpc_id . should . equal ( vpc1 . id ) #NEWLINE# vpc2 = vpc_conn . create_vpc ( '10.1.0.0/16' ) #NEWLINE# template [ 'Resources' ] [ 'test-security-group' ] [ 'Properties' ] [ 'VpcId' ] = vpc2 . id #NEWLINE# template_json = json . dumps ( template ) #NEWLINE# cf_conn . update_stack ( 'test_stack' , template_body = template_json ) #NEWLINE# security_group = vpc_conn . get_all_security_groups ( filters = { #NEWLINE# #INDENT# 'tag:sg-name' : 'sg' , #NEWLINE# #UNINDENT# } ) [ 0 ] #NEWLINE# security_group . vpc_id . should . equal ( vpc2 . id )