Boto3

Boto3 is a SDK for Python 3 that is compatible with OUTSCALE’s AWS-Compliant APIs.

This technical guide explains how to get started with Boto3.

Installing Boto3

Before you begin: Make sure Python 3.8 or later and pip are installed on your machine.

Run the following command in your terminal:

pip install boto3

Boto3 is now installed.

Configuring Boto3

You can set up your Boto3 credentials using one of the following methods:

The endpoint can only be configured when instantiating the boto3.client() object.

Setting Up Environment Variables

The export variables are:

  • AWS_ACCESS_KEY_ID

  • AWS_SECRET_ACCESS_KEY

Set them with the adequate values.

Setting Up Configuration Files

You can edit the following files:

  • ~/.aws/credentials

  • ~/.aws/config

  • /etc/boto.cfg

  • ~/.boto

To configure one of these files, use the following elements:

[<PROFILE_NAME>]
aws_access_key_id=<ACCESS_KEY_ID>
aws_secret_access_key=<SECRET_KEY_ID>

Setting Up a Connector Through a Low-Level Client

You can set aws_access_key_id and aws_secret_access_key as parameters of the boto3.client() object, or use previous methods. However, the region_name and endpoint_url parameters must be configured as follows:

import boto3

connection = boto3.client(
    "<SERVICE_NAME>",
    aws_access_key_id="<ACCESS_KEY_ID>",
    aws_secret_access_key="<SECRET_ACCESS_KEY>",
    region_name="eu-west-2",
    endpoint_url="https://fcu.eu-west-2.outscale.com",
)

Initializing Boto3

Below is an example using Boto3 to connect to the OUTSCALE EC2-like service called FCU. For more information about our services and APIs, see About the APIs.

import boto3

connection = boto3.client(
    "ec2",
    aws_access_key_id="<ACCESS_KEY_ID>",
    aws_secret_access_key="<SECRET_ACCESS_KEY>",
    region_name="eu-west-2",
    endpoint_url="https://fcu.eu-west-2.outscale.com",
)

connection.describe_instances()

The first parameter of the boto3.client() object is the service name. The Boto3 SDK is built to run on Amazon APIs, which have equivalents in the OUTSCALE Cloud (for example, Amazon’s EC2 API is equivalent to OUTSCALE’s FCU API). You need to configure the service name with the Amazon name.

The following table presents the Amazon equivalent for each OUTSCALE service name:

OUTSCALE Service Name Amazon Service Name

fcu

ec2

lbu

elb

eim

iam

directlink

directconnect

oos

s3

For more information about the APIs provided by OUTSCALE, see API Endpoints Reference.

Related Pages

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.