sfl0r3nz05 / DockerSwitchAWSEC2

Creation of API based on Docker to manage AWS EC2 instances on/off.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Docker API to manage on/off AWS EC2 instances

  • Creation of API based on Docker to manage AWS EC2 instances on/off.

Demonstration

Prerequisite

  1. Install docker on ubunu.
  2. Manage Docker as a non-root user.
  3. Install docker compose on ubunu.

How to use

  1. Rename .env.example as .env.

  2. Set the enviromental variables:

    AWS_ACCESS_KEY_ID=XXX
    AWS_SECRET_ACCESS_KEY=XXX
    AWS_SESSION_TOKEN=XXX
    REGION_NAME=XXX
  3. Deploy the containers

    docker compose up -d
  4. Stop the containers

    docker comopose down

How to develop

  1. Modify docker-compose.yml file:

    • From this line:
    image: sflorenz05/api-aws-mngmt:v0.1
    • To this line:
    build: api-ec2/
  2. Repository structure

    • API-EC2
    /api-ec2
        |_ /api
            |_ main.py
                |_ status_ec2.py
                |_ start_ec2.py
                |_ stop_ec2.py
    • Swagger
      • Modify *.json file to e.g., introduce new endpoints:
    /swagger
        |_ swagger.json
  3. Introduce new endpoints or improve improve existing ones

    1. Crete/modify the endpoint in main.py file.
    2. Crete/modify the fuctionality through files such as start_ec2.py.

About

Creation of API based on Docker to manage AWS EC2 instances on/off.


Languages

Language:Python 97.3%Language:Dockerfile 1.6%Language:Shell 1.1%