Skip to content

sachaos/s3env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

s3env

Description

Load environment variables from AWS S3.

Usage

Setup

1. Upload environment variable

Create a bucket and, put a dotenv format file.
Optionally, you can use base64 encoded file.

$ cat dotenv
# This is a comment
ENABLE_DEBUG_MODE=y # comment
ENABLE_TEST_MODE=${ENABLE_DEBUG_MODE}"

$ cat dotenv | base64 | aws s3 cp - s3://your-bucket-name/dotenv # Upload to s3

2. Set AWS credential and s3env environment variables

Set below environment variables, and aws credential environment variables.

S3ENV_BASE64ENCODE=y
S3ENV_BUCKET_NAME=your-bucket-name
S3ENV_KEY_NAME=dotenv

Use environment variable from S3

Load to current shell

$ source <(s3env show --export)
$ echo $ENABLE_DEBUG_MODE
y

Run with some command

$ s3env run irb
irb(main):001:0> ENV["ENABLE_DEBUG_MODE"]
=> "y"

Inspired by