diff --git a/examples/v2/runtimeconfig-variables/README.md b/examples/v2/runtimeconfig-variables/README.md new file mode 100644 index 000000000..636ad7ea1 --- /dev/null +++ b/examples/v2/runtimeconfig-variables/README.md @@ -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/) \ No newline at end of file diff --git a/examples/v2/runtimeconfig-variables/img/runtimeconfig-variables.png b/examples/v2/runtimeconfig-variables/img/runtimeconfig-variables.png new file mode 100644 index 000000000..ab617c1bb Binary files /dev/null and b/examples/v2/runtimeconfig-variables/img/runtimeconfig-variables.png differ diff --git a/examples/v2/runtimeconfig-variables/img/variables.png b/examples/v2/runtimeconfig-variables/img/variables.png new file mode 100644 index 000000000..89e5ff5e5 Binary files /dev/null and b/examples/v2/runtimeconfig-variables/img/variables.png differ diff --git a/examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja b/examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja new file mode 100644 index 000000000..a17115079 --- /dev/null +++ b/examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja @@ -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 }} + diff --git a/examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja.schema b/examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja.schema new file mode 100644 index 000000000..73a9e7ad9 --- /dev/null +++ b/examples/v2/runtimeconfig-variables/runtimeconfig-variables.jinja.schema @@ -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 diff --git a/examples/v2/runtimeconfig-variables/runtimeconfig-variables.yaml b/examples/v2/runtimeconfig-variables/runtimeconfig-variables.yaml new file mode 100644 index 000000000..883a711dc --- /dev/null +++ b/examples/v2/runtimeconfig-variables/runtimeconfig-variables.yaml @@ -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