Skip to content

Instantly share code, notes, and snippets.

@briceburg
Last active March 7, 2023 17:43
Show Gist options
  • Save briceburg/8fafaa2e2ad7dde5a392db2f50cb4d3f to your computer and use it in GitHub Desktop.
Save briceburg/8fafaa2e2ad7dde5a392db2f50cb4d3f to your computer and use it in GitHub Desktop.
Aligning RAILS_ENV, DD_ENV, Amplify Stage, Namespace Stage in AWS Deployments

Questions

  • should RAILS_ENV == DD_ENV
  • should DD_ENV == NAMESPACE_STAGE

how do we make these decisions?

current environment

  • lower level deployed heroku apps use 'staging' as RAILS_ENV.
  • prod uses 'production' as RAILS_ENV
  • the namespace stage is either PRODUCTION, DEVELOPMENT or STAGING depending on the deployment account;
Account Namespace Stage Deployment Environments
ftf-radix-production PRODUCTION radix-prod, environments w/ prod data
ftf-radix-staging STAGING radix-stg, and PR/review environments
ftf-radix-development DEVELOPMENT radix-dev, and sandbox environments

considertations

  • We are setting default values. RAILS_ENV, DD_ENV, &c can be explicitly provided per deployment environment.
  • We can add additional NAMESPACE_STAGES. these could align w/ AMPLIFY_STAGES, currently; PRODUCTION, BETA, DEVELOPMENT, EXPERIMENTAL, PULL_REQUEST
  • local rails development currently uses RAILS_ENV=development

Recommendation

  1. We base RAILS_ENV on the namespace stage
NAMESPACE_STAGE RAILS_ENV
PRODUCTION production
DEVELOPMENT development
STAGING staging

thus RAILS_ENV=development remains for local development (in docker compose). TODO: is this what we want? is local dev (docker compose) set to "development" in other rails services? what is community standard?

  1. We set DD_ENV to Environment tag, aka terraform.workspace
WORKSPACE DD_ENV
prod prod
dev dev
sandbox sandbox
  1. Pull request / review / qa environments will be given the STAGING namespace stage, and thus staging RAILS_ENV.

Examples

Deployment ID NAMESPACE_STAGE RAILS_ENV DD_ENV
radix-prod PRODUCTION production prod
radix-stg STAGING staging stg
radix-dev DEVELOPMENT development dev
radix-sandbox DEVELOPMENT development sandbox
radix-pr-73 STAGING staging pr-73

(local development would continue to use development as RAILS_ENV)

@taylor-kems
Copy link

😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment