Sync your environment files securely with public/private key encryption via AWS S3.
envsync is a CLI tool designed to securely synchronize your .env files across different machines. It uses public/private key encryption for security and AWS S3 for storage.
init: Initialize yourenvsync. This command sets up public/private keys and configures AWS S3.push: Push your.envfile from the current directory to the S3 bucket.pull: Pull your.envfile from the S3 bucket to the current directory.
-
S3 Bucket: Set up an S3 bucket, e.g.,
your-s3-bucket. -
IAM User: Create an IAM user in AWS and attach the following policy for necessary permissions:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "s3:PutObject", "s3:PutObjectAcl", "s3:GetObject" ], "Resource": "arn:aws:s3:::your-s3-bucket/*" } ] } -
AWS Credentials: Note down the IAM user’s
access_key_idandsecret_access_key.
Run envsync init and input the AWS configuration when prompted. This will set up the necessary keys and configuration for envsync.
-
Pushing
.envFile:To push the
.envfile from your current directory to S3, run:envsync push --name=yourprojectname
This command encrypts your
.envfile and stores it atyour-s3-bucket/yourprojectname/.envin S3. -
Pulling
.envFile:To pull the
.envfile from S3, run:envsync pull --name=yourprojectname
For team collaboration, follow these steps:
-
IAM Permissions: Ensure team members have the necessary IAM permissions (refer to the policy mentioned above).
-
Key Sharing: Share the public and private keys located in
$HOME/.envsync/with your team. -
Team Setup: Team members should run
envsync initand configure their environment. They have two options:-
Using Shared Keys: Replace their
private_key.pemandpublic_key.pemfiles with the shared keys and simply run:envsync pull --name=yourprojectname
-
Using a Configuration File: Create their own configuration file and run:
aws: region: ap-southeast-1 s3_bucket: your-s3-bucket access_key_id: your-aws-access-key secret_access_key: your-aws-secret-key envsync: private_key: ~/.envsync/private_key.pem public_key: ~/.envsync/public_key.pem
envsync pull --name=yourprojectname --config=yourconfig.yaml
This approach allows team members to either share keys or use individual configurations, providing flexibility in managing access and security.
-