Using Variables
Efficiently control your application's behavior across various stages with environment variables
In CloudStation, service variables play a pivotal role by being available during build, deployment, and runtime processes. These variables are accessible to your application as environment variables.
You'll find service variables in the following contexts:
- Service deployment's build process
- Active service deployment
- Invoked command instances
Variables
When you deploy a project for the first time, you can define variables within the deployment form under the "Environment Variables" section. Simply add your desired Keys and Values there.
To manage variables, navigate to the "Variables" tab in CloudStation's project view panel. You can tailor variables for each environment specific to the project or service.
Shared Variables
Shared variables help reduce duplication of variables across multiple services within the same project.
Define a Shared Variable
From your Service -> Shared Variables tab, New variable, enter the variable name and value, and click Add
.
Use a Shared Variable
To use a shared variable in your service, follow these steps:
- Navigate to the "Variables -> Shared Variables" tab of your service.
- Click on " + New Variable".
- In the "Key" field, enter the name of the shared variable you want to use.
- In the "Value" field, use the syntax
${SHARED_VARIABLE_NAME}
to reference the shared variable. - Click
Add
to apply the changes.
This allows your service to dynamically reference the shared variable's value, ensuring consistency across your project.
Service Discovery
Variables scoped to individual services can be defined by navigating to a service's "Variables" tab.
Adding new service discovery variables
Form services
- From the list of available services, choose the relevant service for which you want to add an ENV.
Choose the Service Port
- Choose the appropriate port associated with the selected service.
Enter the Key and Value
- In the "Key" field, enter the name of the environment variable you want to create (e.g., DB_USER, REDIS_URL).
- In the "Value" field, provide the value corresponding to the key (e.g., admin, localhost:6379).
Edit this file on GitHub