A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/deployment-manager/docs/configuration/templates/use-environment-variables below:

Using deployment-specific environment variables | Cloud Deployment Manager Documentation

Using deployment-specific environment variables

Stay organized with collections Save and categorize content based on your preferences.

For each of your deployments, Deployment Manager creates pre-defined environment variables that contain information inferred from your deployment. Use these environment variables in your Python or Jinja2 templates to get information about your project or deployment.

Before you begin Available environment variables

The following environment variables are automatically set by Deployment Manager. They are replaced everywhere you use them in your templates. For example, use the project_number variable to add the project number to the name of a service account.

Environment variable Value deployment The name of the deployment. name The name declared in the configuration that is using the template. This can be useful if you want the name you declare in the configuration to be the name of the resource in the underlying templates. project The project ID for this deployment. project_number The project number for this deployment. current_time The UTC timestamp when expansion started for the deployment. type The resource type declared in the top-level configuration. username The current Deployment Manager user. Using an environment variable

Use the following syntax to add an environment variable to your templates:

{{ env["deployment"] }} # Jinja

context.env["deployment"] # Python

In your template, use the variables as in these examples:

Jinja
- type: compute.v1.instance
  name: vm-{{ env["deployment"] }}
  properties:
    machineType: zones/us-central1-a/machineTypes/f1-micro
    serviceAccounts:
    - email: {{ env['project_number'] }}-compute@developer.gserviceaccount.com
      scopes:
      - ...
Python
def GenerateConfig(context):
  resources = []
  resources.append ({
    'name': 'vm-' + context.env["deployment"],
    'type': 'compute.v1.instance',
    'properties': {
       'serviceAccounts': [{
         'email': context.env['project_number'] + '-compute@developer.gserviceaccount.com',
         'scopes': [...]
       }]
    }
    ...}]
  return {'resources': resources}
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Deployment Manager automatically creates environment variables for each deployment, providing information about the project and deployment."],["These environment variables, such as `deployment`, `project`, and `project_number`, can be used within Jinja2 or Python templates to dynamically configure resources."],["The `current_time` environment variable provides a UTC timestamp of when the deployment expansion started."],["Templates utilize environment variables using the `{{ env[\"variable_name\"] }}` syntax for Jinja2 and `context.env[\"variable_name\"]` for Python."],["Environment variables can be used to define or alter resource names and properties within a template, such as appending the deployment name to a VM instance."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4