- Home
- Score
- Working with
- Workload variables
-
- Overview
-
- Overview
- Deploy your Application
- Manage your Java application
- Migrate an Application
- Provision Amazon S3 Buckets
- Deploy an Amazon S3 Resource to production
- Set up the reference architecture in your cloud
- Scaffold a new Workload and create staging and prod Environments
- Update Resource Definitions for related Applications
- Provision a Redis cluster on AWS using Terraform
- Perform daily developer activities (debug, rollback, diffs, logs)
- Deploy ephemeral Environments
-
-
Workload variables
Use Score to pass environment configurations at the Workload level.
On this page
Values and Secrets are defined inside the Humanitec application and can be set Environment wide.
However, you can define Workload level Values and Secrets with Score.
Overview #
The Score Specification uses a special environment
property type that is specified in the resources
section.
apiVersion: score.sh/v1b1
metadata:
name: hello-world
containers:
hello:
image: busybox
command: ["/bin/sh"]
args: ["-c", "while true; do echo Hello $${FRIEND}!; sleep 5; done"]
variables:
FRIEND: ${resources.env.NAME}
resources:
env:
type: environment
Resources need to map to the resource structure.
To declare environment variables in a Score file, the variable name,
resources.env.NAME
must map to the structure in resources
section.Use the run
command to generate a Humanitec deployment delta file from Score.
humctl score deploy --dry-run -f ./score.yaml \
--env test-env
The following is the output of the previous command.
{
"metadata": {
"env_id": "test-env",
"name": "Auto-generated (SCORE)"
},
"modules": {
"add": {
"hello-world": {
"profile": "humanitec/default-module",
"spec": {
"containers": {
"hello": {
"args": [
"-c",
"while true; do echo Hello $${FRIEND}!; sleep 5; done"
],
"command": ["/bin/sh"],
"id": "hello",
"image": "busybox",
"variables": {
"FRIEND": "${values.NAME}"
}
}
}
}
}
}
}
}
The output JSON can be used as a payload to Create a new Delta with a Humanitec API call.
When deploying this service with Humanitec, make sure the shared application value called NAME
is created and set for the target environment.