Skip to content

Instantly share code, notes, and snippets.

@akiatoji
Created May 23, 2019 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akiatoji/0223d293a71b922b68ad1d8f525b6efb to your computer and use it in GitHub Desktop.
Save akiatoji/0223d293a71b922b68ad1d8f525b6efb to your computer and use it in GitHub Desktop.
import os
import uuid
from google.cloud import storage, kms_v1
def load(app):
config_file_name = "secrets-%s.cfg" % str(uuid.uuid4())
storage_client = storage.Client()
bucket = storage_client.get_bucket('vault')
blob = bucket.blob('secrets.cfg')
blob.download_to_filename(config_file_name)
try:
app.config.from_pyfile(config_file_name)
finally:
os.remove(config_file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment