def list_instances(session, instances, project_name, states, include_states): """List EC2 instances.""" aok, err = EC2InstanceManager(session.get_ec2_session()).\ list_instances(instances, project_name, states, include_states) if not aok: print(err)
def terminate_instances(session, instances, project_name): """Delete one or more or all EC2 instances.""" _, status = EC2InstanceManager(session.get_ec2_session()).\ terminate_instances(instances, project_name) print() print(status)
def stop_instances(session, instances, force, project_name): """Stop EC2 instances.""" if not force and project_name is None: print('Please Specify Project Name associated with Instances') return _, err = EC2InstanceManager(session.get_ec2_session()).\ stop_instances(instances, project_name) print() print(err)
def modify_instances(session, instances, security_groups, enable_source_dest_check, user_data, user_data_file, project_name, instance_names, iam_instance_profile_arn, attach_iam_role): """Modify EC2 instances.""" _, err = EC2InstanceManager(session.get_ec2_session()).\ modify_instances(instances, security_groups, enable_source_dest_check, user_data, user_data_file, project_name, instance_names, iam_instance_profile_arn, attach_iam_role) print() print(err)
def create_instances(session, image_name, instance_type, security_groups, key_name, min_count, max_count, subnet_id, user_data, user_data_file, project_name, instance_name, iam_instance_profile_arn): """Create one or more EC2 instances. image-name - name of the image. instance-type - type of the instance. key-name - a valid key-name to login to the ec2 isntances. Note : image-names are the same across regions bu the images ids differ from region to region. """ _, status = EC2InstanceManager(session.get_ec2_session()).\ create_instances(image_name, instance_type, security_groups, key_name, min_count, max_count, subnet_id, user_data, user_data_file, project_name, instance_name, iam_instance_profile_arn) print() print(status)