Git Product home page Git Product logo

python-with-secrets-manager's Introduction

python-with-secrets-manager

This is a very basic FastAPI application that makes use of Secrets Manager Providers like AWS & GCP.

You can take reference from the code for better understanding, below are listed a few points to be noted for using and managing secrets in Secrets Manager Provider.

  1. AWS provides us option to add Other type of secret which basically allows us to store Key/Value pairs as secrets, this is very helpful as we can store lots of key value pairs and make use of them as a dictionary in Python code. AWS - Other type of secret

  2. On the other hand, GCP does not allow this option and instead we have a text based input, but we can definitely enter JSON format there and store it and later on access this as a dictionary in Python code. GCP - Text type of secret only

  3. We are using lru_cache from itertools to cache our secrets once they have being retrieved in the Python code, which is a good way to fetch secrets very fast after initial loading but the secrets value won't change until the server has been restarted which is serving FastAPI app.

  4. AttrDict -> This is a custom written utility which helps to convert a Python dict to a class object which has access to all the dict keys using . notation. For e.g. if a secret is {"API_VERSION": "14"} then using AttrDict instance we can access it using attr_dict_instance.API_VERSION # output -> 14

  5. We can even use region wise secrets by defining the secrets in multiple regions of Secrets Manager Provider (AWS / GCP). This can be helpful when we have different servers in different regions and we want to match the Secrets with those regions and access accordingly.

AWS Setup

AWS - Image showing secret stored in AWS console

GCP Setup

GCP - Image showing secret stored in GCP console

python-with-secrets-manager's People

Contributors

alexmhack avatar

Watchers

 avatar  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.