-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Summary
This issue proposes the implementation of a feature for adding support for RAIN_VAR_ and rain_TAG_ environment variable prefixes to be leveraged for auto-populating arguments for the command line, similar to how TF_VAR_ and TF_AWS_DEFAULT_TAGS_ are supported in Terraform and the AWS Provider.
Motivation
In cloud-first environments, there is a strong emphasis on resource tagging and per-user or per-environment configurations. Terraform's standardized environment variable prefixes (TF_VAR_ for variables, TF_AWS_DEFAULT_TAGS_ for default tags) make it easier for users to inject configuration and tags by cross-cutting concerns, like these values being configured by default within a .devcontainer, or the tags populated by some automated tooling.
Rain could provide a similar user experience for CloudFormation deployments by supporting RAIN_VAR_ (for parameters) and RAIN_TAG_ (for resource tags) environment variables.
Note
This doesn't have to be the prefix RAIN_VAR_, could be CF_VAR_ or anything else.
Feature
- RAIN_VAR_: Any environment variable prefixed with
RAIN_VAR_would be automatically interpreted as a CloudFormation parameter. Example:RAIN_VAR_MyParam=foowould set the parameterMyParamtofoo. - RAIN_TAG_: Any environment variable prefixed with
RAIN_TAG_would be automatically collected and attached as a tag to deployed resources. Example:RAIN_TAG_Environment=devwould result in a resource tagEnvironment=devon all applicable resources. - Any arguments passed to the command line (
--params,--tags) would override the environment variable value - The environment variable behaviour could be default & opt-out (
--no-source-env), opt-in (--env-from) or baseline
Users would then be able to have the following work to pass parameters:
# Set CloudFormation parameters 'MyParam1' and 'MyParam2'
export RAIN_VAR_MyParam1=value1
export RAIN_VAR_MyParam2=value2
# Set CloudFormation tags 'Environment' and 'Owner'
export RAIN_TAG_Environment=dev
export RAIN_TAG_Owner=$USER
# Deploy with Rain (environment variables are automatically picked up)
rain deploy my-stack template.yaml
# Equivalent command:
# rain deploy my-stack template.yaml \
# --params MyParam1=value1 MyParam2=value2 \
# --tags Environment=dev Owner=aliceUse Cases
- CI/CD pipelines that standardize tagging and configuration through environment variables, allowing you to deploy any template and just set the environment variables to pass along tags
- Developers deploying resources in shared environments who need to inject per-user or per-project tags and parameters (ex. Owner, Custodian, Developer, Timezone, etc)
- Scripts abstractions don't require explicit handling of all tagging & parameters, and can instead provide things as needed