Introduction and installation of the "Amazon EC2 Python API Series" Boto

Source: Internet
Author: User
Tags aws sdk

Boto is the AWS SDK for Python.

All of the environments in this article are under the Linux operating system.

Installation:

git clone https://github.com/awslabs/aws-python-sample.git
Pip Install Boto
If the PIP is not installed, refer to the installation steps here: http://pip.readthedocs.org/en/latest/installing.html

Configuration:

There are two types of configuration files for Boto:

1. User home Directory Profile ~/.boto, this file is only useful for this user.

2. Global configuration file/etc/boto.cfg, valid for all users.

These two files need to be created on demand, and the main purpose is to store validation information for the AWS API:

Aws_access_key_id=xxxx

Aws_secret_access_key=xxxx

Here are two values to get in your AWS account, how to get it, see the picture






Click Crete New access key and you will get access key ID and secret access key which is the two authentication values that need to be configured in the Boto configuration file, equivalent to the credentials of the API connecting to AWS. The purpose of creating this profile is to make sure that you do not have to write the credentials into the code during the development process, but you can also write to the code without creating the configuration file.

Connection EC2:

Import Boto.ec2conn = Boto.ec2.connect_to_region ("ap-northeast-1")

The above code can be connected to the corresponding area of EC2, please refer to the area code:

Code name

ap-northeast-1

Asia Pacific Region (Tokyo)

ap-southeast-1

Asia Pacific Region (Singapore)

ap-southeast-2

Asia Pacific Region (Sydney)

eu-central-1

Europe (Frankfurt)

eu-west-1

Europe (Ireland)

sa-east-1

South America (Sao Paulo)

us-east-1

US East (N. Virginia)

us-west-1

US West (Northern California)

us-west-2

US West (Oregon)

Connect_to_region () has many properties, most commonly

region= ' us-east-1 ' value here is the default value

Aws_access_key_id=xxxx

Aws_secret_access_key=xxxx

The credentials here are the same as the values in the Boto configuration file. Connect_to_region will read the credentials from the Boto configuration file and must be specified if there is no Boto configuration file.

Connect_to_region () returns the instantiation of Class boto.ec2.connection.EC2Connection, which is boto.ec2.connection.

What can I do with this class in the next section? For example, conn.get_all_instances () can get all instance in your area reservations

Introduction and installation of the "Amazon EC2 Python API Series" Boto

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.