Giter Site home page Giter Site logo

cloud-agnostic's Introduction

cloud-agnostic

Generic library to abstract common cloud API calls

Overview

What is Cloud Agnostic?

Everything was fine when I purely developed on AWS, but then my clients started asking to move code to other platforms. Many of my Python scripts had hard-coded boto3 references, making the code impossible to run on another platform. The use of docker containers however makes the transporting of software in a container much easier. The challenge however is that the business logic part of the code still needed to interact with the cloud backend in some shape or form. That's where CloudAgnostic comes in.

CloudAgnostic creates an abstraction layer between the Cloud SDK tools, and your software, thus negating the need for you to write code for AWS, GCP and Azure. You simply make the call, and provided the parameters have been provided, CloudAgnostic will make the call for you.

But there's hardly anything in it?!!

This is a brand new project. As I need things, I add them in.

  • Found a bug? Raise an issue
  • Want to add a new feature? Submit a PR!

Keeping it simple

Each cloud platform has their own nuances in how they operate. Not every possible scenario could always be accounted for, but we'll try. The goal will be to "keep it simple". Instead of building a function that can do everything, we'll build a function that does just one thing. For example, you want to write a blob to a storage account, use the write function. It takes just two parameters, the target, and the body. Your software need to keep some variable somewhere to say what the target should be (ie s3://bucket/key.txt). If you port your software to another platform, you just have to account for this variable. Anywhere in your code where you call CA.write(target,body), it will write to that storage account, regardless of what the platform is.

This is too complicated. Just use boto3!

I believe there will be use-cases where you may have to use the vendor SDK instead of CloudAgnostic simply because your own requirements may be more complex than what CloudAgnostic can offer you.

If however you do find an opportunity to expand the usage of CloudAgnostic to support your particular use case, you can always create a Pull Request and include your code to the project, or head on over to the discussion forum to share your ideas.

Functions

Function What it does Local AWS Azure GCP
alert Sends a message slack SNS no no
list List the contents of a storage account no no no no
read Reads from blob storage local disk s3 bucket no no
write Writes a blob to storage local disk s3 bucket no gs
secret Retrieves a secret no secretsmanager no no

Installation

$ git clone https://github.com/massyn/cloud-agnostic
$ pip install -r cloud-agnostic/requirements.txt

Examples

Write a file

from cloudagnostic import CloudAgnostic
CA = CloudAgnostic()

CA.write('s3://bucket/key.txt','hello world')   # AWS S3
CA.write('gs://bucket/key.txt','hello world')   # Google
CA.write('/tmp/key.txt','hello world')  # local file

Send an alert

Slack

from cloudagnostic import CloudAgnostic
CA = CloudAgnostic(alert = 'https://hooks.slack.com/services/.....')
CA.alert('INFO','hello world')

AWS SNS

from cloudagnostic import CloudAgnostic
CA = CloudAgnostic(alert = 'arn:aws:sns:ap-southeast-2:000000000000:mytopic')
CA.alert('INFO','hello world')

Secret

from cloudagnostic import CloudAgnostic
CA = CloudAgnostic()

x = CA.secret('arn:aws:secretsmanager:ap-southeast-2:000000000000:secret:yyyyy')    # AWS Secrets Manager

cloud-agnostic's People

Contributors

massyn avatar snyk-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.