AWS Software Development Kits (SDKs)
Here, we will learn about AWS Software Development Kits (SDKs).
What are AWS Software Development Kits (SDKs)?
AWS offers a number of SDKs for use by programmers. Even though we don’t expect that a systems operator would use an SDK directly on a regular basis, as a knowledgeable AWS resource, it’s important that you understand that the SDKs and the underlying APIs they use exist, and that you have some general knowledge about how they are used. It is primarily through the AWS SDKs and the APIs that underlie them that applications built on AWS can manage infrastructure as code. The concept of infrastructure as code is powerful, disruptive, and sets the cloud apart from the old IT world.
AWS SDKs were available for the following programming languages like – Android, Browser (JavaScript), iOS, Java, .NET, Node.js, PHP, Python, Ruby, Go and C++
Primarily specific SDKs have the following purpose –
- AWS Mobile SDK
- AWS IoT Device SDK
We shall now discuss some of the commonly used AWS SDKs –
Boto
AWS SDK for Python also referred as Boto. Just like any other AWS SDKs and many of our tools, boto is available as an open source project in GitHub for the community to view freely, download, and branch under the terms of its license. Primarily there is an active Boto community, like as a chat group, that can help answer questions.
Process of installing Boto
Since Boto is an SDK for Python, it requires Python to be installed prior to its own installation. We can find more information about installing Python at http://www.python.org/. Some other prerequisite is pip, a Python tool for installing packages, which can be found at https://pip.pypa.io/.
After installing Python and pip, we can install Boto using the following command – pip install boto3
Features of Boto
Boto contains a variety of APIs that operate at either a high level or a low level. AWS Cloud service-specific APIs maps the low-level APIs (Client APIs). The details of how to use the low-level APIs are in the Boto 3 documentation at https://boto3.readthedocs.io/en/latest/guide/clients.html. The higher-level option, Resource APIs, allows you to avoid calling the network at the low level and instead provide an object-oriented way to interact with AWS Cloud services. Boto also has a helpful feature called the waiter which provides a structure that allows for code to wait for changes to occur in the cloud.
Now if we want to use Boto in the Python code, we start by importing the Boto SDK – import boto3
Also, if we are using Interactive mode, we then press Enter.
Using Resource Application Programming Interfaces (APIs)
In order to use the Boto class in Python, you have to invoke it by calling boto3.resource and passing in a service name in single quotes. For instance, if you want to perform an action using Amazon EC2, then it would be required to execute something like –
ec2 = boto3.resource(‘ec2’)
Here, we have an object here ec2, which acts on Amazon EC2 instances in the AWS account. We can then instantiate a method object pointing to a specific instance in the Amazon Virtual Private Cloud (Amazon VPC) –
myinstance = ec2.Instance(‘i-0bxxxxxxxxxxxxxxx’)
Now in case you wish to stop an Amazon EC2 instance programmatically, possibly at the end of a shift to save money when it is not in use. You can then issue a command to stop that instance – myinstance.stop()
We can start the instance back up again automatically prior to the beginning of the next shift – myinstance.start()