Resource Definitions
Driver
Capability
Flavor
Resource Type
Environment Varaiables
This section contains example Resource Definitions using the Template Driver for injecting environment variables in your containers.
inject-env-var-to-workload.yaml
: Add the required environment variables to the Workload so they become available inside the containers. This format is for use with the Humanitec CLI .inject-env-var-to-workload.tf
: This format is for use with the Humanitec Terraform Provider .
Resource Definitions #
inject-env-var-to-workload.yaml
(view on GitHub )
:
# This Resource Definition uses the Template Driver
# to add inject environment variables to a Workload
apiVersion: entity.humanitec.io/v1b1
kind: Definition
metadata:
id: inject-env-var-to-workload
entity:
name: inject-env-var-to-workload
type: workload
driver_type: humanitec/template
driver_inputs:
values:
templates:
outputs: |
update:
{{- range $containerId, $value := .resource.spec.containers }}
- op: add
path: /spec/containers/{{ $containerId }}/env
value:
- name: MY_ENV_VAR_A
value: "my env value A"
- name: MY_ENV_VAR_B
value: "my env value B"
- name: MY_ENV_VAR_C
value: "my env value C"
{{- end }}
inject-env-var-to-workload.tf
(view on GitHub )
:
resource "humanitec_resource_definition" "inject-env-var-to-workload" {
driver_type = "humanitec/template"
id = "inject-env-var-to-workload"
name = "inject-env-var-to-workload"
type = "workload"
driver_inputs = {
values_string = jsonencode({
"templates" = {
"outputs" = "update:\n {{- range $containerId, $value := .resource.spec.containers }}\n - op: add\n path: /spec/containers/{{ $containerId }}/env\n value:\n - name: MY_ENV_VAR_A\n value: \"my env value A\"\n - name: MY_ENV_VAR_B\n value: \"my env value B\"\n - name: MY_ENV_VAR_C\n value: \"my env value C\"\n {{- end }}"
}
})
}
}