Skip to content

Production .envrc files for AWS, GCP, Python, Kubernetes and Terraform with cloud auto-login and auto EKS / GKE context and namespace switching

License

Notifications You must be signed in to change notification settings

HariSekhon/Environments

Repository files navigation

Hari Sekhon - Environments

GitHub starsGitHub forksLineCountCocomoLicenseMy LinkedInGitHub Last Commit

Codacy BadgeCodeFactorQuality Gate StatusMaintainability RatingReliability RatingSecurity Rating

PythonLinuxMac

Mac HomebrewAlpineCentOSDebianFedoraRedhatRockyUbuntu

CI Builds OverviewAzure DevOps PipelineGitLab PipelineBitBucket Pipeline

Repo on GitHubRepo on GitLabRepo on Azure DevOpsRepo on BitBucket

MarkdownValidationKicsGrypeSemgrepSemgrep CloudSonarCloudTrivy

Environments

Quick Setup

Edit the <cloud>/<environment>/.envrc files with the profiles, regions, and other settings for your environments:

"$EDITOR" aws/dev/.envrc

Then just run make from the top level directory to install direnv and approve all the .envrc files:

make

Now whenever you cd into one of the <cloud>/<environment> directories it'll automatically:

  • configure your cloud CLI settings, such as your:
    • AWS:
      • profile
      • region
      • EKS cluster
    • GCP:
      • project
      • config configuration
      • region (even different regions per service)
      • GKE cluster
  • switch your kubectl context to the right Kubernetes cluster
  • set any other environment variables you've specified, such as
    • API keys for other services such as Cloudflare
    • AWS or GCP Secret Manager keys that tools use to pull secrets from

Detailed Setup

Install

Install direnv.

For convenience you can just run:

make install

which will attempt to install direnv using whatever your local package manager is, or fall back to binary download.

Configure

Edit the <cloud>/<environment>/.envrc files with the profile config names, regions, kubernetes cluster names and other settings for your environments:

"$EDITOR" aws/dev/.envrc

Approve

Changes to an .envrc require (re)approval for safety.

See aws/README.md or gcp/README.md for more cloud specific information.

Approve Individual .envrc

Approve the $PWD/.envrc changes in the current directory:

direnv allow

Alternatively approve one at a different path:

direnv allow path/to/.envrc
Approve all .envrc

To approve all .envrc under the current directory tree, run this from the top level directory of this repo:

make allow

to direnv allow all the .envrc found in this repo's directory tree.

Directory Structure

$ tree -a aws gcp aws ├── .envrc ├── README.md ├── dev │ └── .envrc ├── prod │ └── .envrc └── staging └── .envrc gcp ├── .envrc ├── README.md ├── dev │ └── .envrc ├── prod │ └── .envrc └── staging └── .envrc

More Core Repos

Knowledge

Readme CardReadme Card

DevOps Code

Readme CardReadme CardReadme CardReadme Card

Containerization

Readme CardReadme Card

CI/CD

Readme CardReadme Card

Databases - DBA - SQL

Readme Card

DevOps Reloaded

Readme CardReadme CardReadme CardReadme CardReadme Card

Monitoring

Readme CardReadme CardReadme Card

Templates

Readme CardReadme Card

Desktop

Readme CardReadme Card

Spotify

Readme CardReadme Card

The rest of my original source repos are here.

Pre-built Docker images are available on my DockerHub.

About

Production .envrc files for AWS, GCP, Python, Kubernetes and Terraform with cloud auto-login and auto EKS / GKE context and namespace switching

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published