#NEWLINE# @ mock_ec2 ( ) #NEWLINE# @ mock_cloudformation ( ) #NEWLINE# def test_vpc_single_instance_in_subnet( ) : #NEWLINE# #INDENT# template_json = json . dumps ( vpc_single_instance_in_subnet . template ) #NEWLINE# conn = boto . cloudformation . connect_to_region ( 'us-west-1' ) #NEWLINE# conn . create_stack ( 'test_stack' , template_body = template_json , parameters = [ ( 'KeyName' , 'my_key' ) ] ) #NEWLINE# vpc_conn = boto . vpc . connect_to_region ( 'us-west-1' ) #NEWLINE# vpc = vpc_conn . get_all_vpcs ( ) [ 0 ] #NEWLINE# vpc . cidr_block . should . equal ( '10.0.0.0/16' ) #NEWLINE# subnet = vpc_conn . get_all_subnets ( ) [ 0 ] #NEWLINE# subnet . vpc_id . should . equal ( vpc . id ) #NEWLINE# ec2_conn = boto . ec2 . connect_to_region ( 'us-west-1' ) #NEWLINE# reservation = ec2_conn . get_all_instances ( ) [ 0 ] #NEWLINE# instance = reservation . instances [ 0 ] #NEWLINE# eip = ec2_conn . get_all_addresses ( ) [ 0 ] #NEWLINE# eip . domain . should . equal ( 'vpc' ) #NEWLINE# eip . instance_id . should . equal ( instance . id ) #NEWLINE# security_group = ec2_conn . get_all_security_groups ( filters = { #NEWLINE# #INDENT# 'vpc_id' : [ vpc . id ] , #NEWLINE# #UNINDENT# } ) [ 0 ] #NEWLINE# security_group . vpc_id . should . equal ( vpc . id ) #NEWLINE# stack = conn . describe_stacks ( ) [ 0 ] #NEWLINE# resources = stack . describe_resources ( ) #NEWLINE# vpc_resource = [ resource for resource in resources if ( resource . resource_type == 'AWS::EC2::VPC' ) ] [ 0 ] #NEWLINE# vpc_resource . physical_resource_id . should . equal ( vpc . id ) #NEWLINE# subnet_resource = [ resource for resource in resources if ( resource . resource_type == 'AWS::EC2::Subnet' ) ] [ 0 ] #NEWLINE# subnet_resource . physical_resource_id . should . equal ( subnet . id ) #NEWLINE# eip_resource = [ resource for resource in resources if ( resource . resource_type == 'AWS::EC2::EIP' ) ] [ 0 ] #NEWLINE# eip_resource . physical_resource_id . should . equal ( eip . allocation_id )