Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions examples/v2/runtimeconfig-variables/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Cloud Runtime Configuration template

## Overview

This is a [Google Cloud Deployment Manager](https://cloud.google.com/deployment-manager/overview) template that deploys a [RuntimeConfig](https://cloud.google.com/deployment-manager/runtime-configurator/) resource, and a list of [Variables](https://cloud.google.com/deployment-manager/runtime-configurator/set-and-get-variables) that belong to the created RuntimeConfig resource.

![Google DM Screenshot](./img/runtimeconfig-variables.png)

## Notes for API explorer Runtime Configurator

To create a configuration ressource:

* parent: `projects/[PROJECT ID]`
* name: `projects/[PROJECT ID]/configs/[CONFIG NAME]`

To create a variable in a configuration ressource:

* parent: `projects/[PROJECT ID]/configs/[CONFIG NAME]`
* name: `projects/[PROJECT ID]/configs/[CONFIG NAME]/variables/[VARIABLE NAME]`

## Deploy the template

Use `runtimeconfig-variables.yaml` to deploy this example template. When ready, deploy with the following command:

```
gcloud deployment-manager deployments create test-run-1 --config runtimeconfig-variables.yaml
```

**`runtimeconfig-variables.yaml`**

```
# title: Runtime Config Variables
# author: osm.hammami@gmail.com
# description: |
# Creates a RuntimeConfig with a list of variables that belong to the created RuntimeConfig resource.
# version: 0.1

imports:
- path: runtimeconfig-variables.jinja

resources:
- name: test-deployment-1
type: runtimeconfig-variables.jinja
properties:
variables:
- name: var1
value: 192.168.1.1
- name: var2
value: 192.168.1.2
- name: var3
value: 192.168.1.3
```

### Deployment

```
# gcloud deployment-manager deployments create test-run-1 --config runtimeconfig-variables.yaml
The fingerprint of the deployment is jAyjD2rn7l0wI3U2QDaykQ==
Waiting for create [operation-1560440335333-58b3653e176e6-f0e46ede-3dc9d076]...done.
Create operation operation-1560440335333-58b3653e176e6-f0e46ede-3dc9d076 completed successfully.
NAME TYPE STATE ERRORS INTENT
test-deployment-1 runtimeconfig.v1beta1.config COMPLETED []
test-deployment-1-var1 runtimeconfig.v1beta1.variable COMPLETED []
test-deployment-1-var2 runtimeconfig.v1beta1.variable COMPLETED []
test-deployment-1-var3 runtimeconfig.v1beta1.variable COMPLETED []
```
To check the deployment use the [runtimeconfig.projects.configs.variables.list](https://developers.google.com/apis-explorer/#p/runtimeconfig/v1beta1/runtimeconfig.projects.configs.variables.list) with the parent exported as an output in the deployment.

#### Request

* parent: `projects/[PROJECT ID]/configs/test-deployment-1`
* returnValues: `true`
* fields: `variables(name,text,value)`

![Google DM Screenshot](./img/variables.png)

## References

* [API reference RuntimeConfig](https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/)
* [API explorer RuntimeConfig v1beta1](https://developers.google.com/apis-explorer/#p/runtimeconfig/v1beta1/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{#
title: Runtime Config
author: osm.hammami@gmail.com
description: |
Creates a RuntimeConfig with a list of variables that belong to a RuntimeConfig created resource.
version: 0.1
#}

{% set ID = env['name'] %}

resources:
- name: {{ ID }}
type: runtimeconfig.v1beta1.config
properties:
config: {{ ID }}

{% if properties['variables'] %}
{% for i in range(properties['variables']| length) %}
- name: {{ ID }}-{{ properties['variables'][i]['name'] }}
type: runtimeconfig.v1beta1.variable
properties:
parent: $(ref.{{ ID }}.name)
variable: {{ properties['variables'][i]['name'] }}
text: {{ properties['variables'][i]['value'] }}
{% if i %}
metadata:
dependsOn:
- {{ ID }}-{{ properties['variables'][i - 1]['name'] }}
{% endif %}
{% endfor %}
{% endif %}

outputs:
- name: runtimeconfig-name
value: {{ ID }}

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
info:
title: Runtime Config Variables
author: osm.hammami@gmail.com
description: |
Creates a RuntimeConfig with a list of variables that belong to a RuntimeConfig created resource.
version: 0.1

imports:
- path: runtimeconfig-variables.jinja

required:
- variables

properties:
variables:
type: array
description: An array of https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs.variables
items:
type: object
required:
- name
- value
properties:
name:
type: string
value:
type:
- integer
- string
20 changes: 20 additions & 0 deletions examples/v2/runtimeconfig-variables/runtimeconfig-variables.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# title: Runtime Config Variables
# author: osm.hammami@gmail.com
# description: |
# Creates a RuntimeConfig with a list of variables that belong to the created RuntimeConfig resource.
# version: 0.1

imports:
- path: runtimeconfig-variables.jinja

resources:
- name: test-deployment-1
type: runtimeconfig-variables.jinja
properties:
variables:
- name: var1
value: 192.168.1.1
- name: var2
value: 192.168.1.2
- name: var3
value: 192.168.1.3