Checkout Environment OutputsWe have released native integration to reuse outputs in env zero, through our new Environment Outputs feature, which also supports the ability to pass secrets!
Benefits of using Environment Outputs:
- native 1st class integration (which means no more API keys)
- ability to support Secrets!
- works with Workflows as well!
Overview
This plugin will fetch output values from another environment and insert them as terraform and/or environment variables. Similar to self hosted agent secrets, use this notation in the value of the terraform input value:${env0:<environment id>:<output name>}${env0:<environment name>:<output name>}(see note below about Environment Names restrictions)${env0-workflow:<parent node name>:<output name>}
{"ENV0_ENVIRONMENT_NAME":<environment name>, "output": <output name>}{"ENV0_WORKFLOW_PARENT":<parent name>, "output": <output name>}
Requirements
To use this plugin, you need to setup the env zero API key and secret for the environment. You can use an Organization API Key or a Personal API Key.ENV0_API_KEY(Required)ENV0_API_SECRET(Required)
Usage
Add the followingenv0.yaml custom flow file to your environment or project.
- Configure the Custom Flow above with a new environment or an existing environment
- Add a Terraform Variable
- The Key is the name of your Terraform variable
- The Value is a reference to another environment’s output variable. With the following format:
${env0:<env0_environment_id>:<output_key>} - Run the environment, and env zero will fetch the value
Workflows
When using the plugin within a workflow you can use the following notation: string types:${env0-workflow:<parent name>:<output name>}json types:
{"ENV0_WORKFLOW_PARENT":<parent name>, "output": <output name>}
In this case, the parent name is the yaml parent, not the “environment name.”For example, given the following env0.workflow.yaml the variable structure to fetch the “vpc-id” from the “parent vpc” would be
${env0-workflow:vpc:vpc-id} Similarly, to fetch the tags (in json) from the vpc: {"ENV0_WORKFLOW_PARENT":vpc, "output": tags}
env0.workflow.yaml
Environment Name Restrictions
- Environment Names must be unique, otherwise, the script just uses the “first” matching environment name.
- Environment Names must not include spaces ” ” or slashes
/. Ideally, your environment only contains alphanumeric characters and dashes-. **
Inputs
N/AExample Usage
In this example we will run fetch the variable from a “Dev VPC” environment.- Configure the Custom Flow above with a new environment or an existing environment
- Add a Terraform Variable
- The
Keyis the name of your Terraform variable - The
Valueis a reference to another environment’s output variable. For example, if I needed the VPC ID from my “Dev VPC” Environment:
- First I need to get the ENV0_ENVIRONMENT_ID from that environment.
note: the Environment ID can be found in the URL:https://app.env0.com/p/7320dd7a-4822-426c-84b5-62ddd8be0799/environments/9cec1eb6-c17f-4cca-9cdf-606a23cdf6b5where9cec1eb6-c17f-4cca-9cdf-606a23cdf6b5is the ENV0_ENVIRONMENT_ID. - Find the output name in the environment Resources tab. e.g.
vpc_id - The value you enter would be then:
${env0:9cec1eb6-c17f-4cca-9cdf-606a23cdf6b5:vpc_id}
- Run the environment, and env zero will fetch the value