Skip to content

Repository files navigation

Python Boto3 Api

Python Boto3 API for AWS

DockerPythonAWSGithub top languageGithub language countRepository sizeLicense

About | Features | Technologies | Requirements | Starting | License | Author


🎯 About

Python API uses the Flask and Boto3 libraries. It has instance listing, instance start, instance stop, instance create and instance terminate features; It has 5 endpoints communicating with EC2 service on AWS.

✨ Features

🚀 Technologies

The following tools were used in this project:

✅ Requirements

Before starting 🏁, you need to have Git and Python installed.

🏁 Starting

# Clone this project
git clone https://github.com/devenes/python-boto3-api
# Accesscd python-boto3-api
# Install dependencies
pip install -r requirements.txt
# Run the project
python app.py
# The server will initialize in the <http://localhost:8080>

Create Instance

You send a POST request to the create endpoint with the following parameters and it will create Ubuntu EC2 instance. You create your EC2 Instance with the region_name, KeyName and SecurityGroupId parameters you send in the request.

http://<api_host>:<api_port>/ec2/create
ParameterTypeDescription
aws_access_key_idstringAWS Access Key ID
aws_secret_access_keystringAWS Secret Access Key
region_namestringAWS Region Name
KeyNamestringAWS Key Name
SecurityGroupIdstringAWS Security Group ID

List Instances

You send a GET request to the list endpoint by entering the following parameters, then you can list all the instances and their status in your AWS account in the region you specify.

http://<api_host>:<api_port>/ec2/list
ParameterTypeDescription
aws_access_key_idstringAWS Access Key ID
aws_secret_access_keystringAWS Secret Access Key
region_namestringAWS Region Name

Start Instance

You send a POST request to the start endpoint by entering the following parameters, and you can start the instance you specified with instance_id, in the region you specified with region_name and the status of the instance will be changed to pending and then to running.

http://<api_host>:<api_port>/ec2/start
ParameterTypeDescription
aws_access_key_idstringAWS Access Key ID
aws_secret_access_keystringAWS Secret Access Key
region_namestringAWS Region Name
instance_idstringInstance ID Number

Stop Instance

You send a POST request to the stop endpoint by entering the following parameters, and you can stop the instance you specified with instance_id, in the region you specified with region_name and the status of the instance will be changed to stopping and then to stopped.

http://<api_host>:<api_port>/ec2/stop
ParameterTypeDescription
aws_access_key_idstringAWS Access Key ID
aws_secret_access_keystringAWS Secret Access Key
region_namestringAWS Region Name
instance_idstringInstance ID Number

Terminate Instance

You send a POST request to the terminate endpoint by entering the following parameters, and you can terminate the instance you specified with instance_id, in the region you specified with region_name and the status of the instance will be changed to shutting-down and then terminated.

http://<api_host>:<api_port>/ec2/terminate
ParameterTypeDescription
aws_access_key_idstringAWS Access Key ID
aws_secret_access_keystringAWS Secret Access Key
region_namestringAWS Region Name
instance_idstringInstance ID Number

Resources

📝 License

This project is under license from MIT. For more details, see the LICENSE file.

Made with ❤️ by devenes

Back to top

About

Python API uses the Flask and Boto3 libraries. It has instance listing, instance start, instance stop, instance create and instance terminate features; It has 5 endpoints communicating with EC2 service on AWS.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages