0

https://cloud.google.com/deployment-manager/docs/configuration/templates/using-schemas

Im using jinja templates that depend on other jinja templates so I MUST use a schema to import them

This is all my schema has in it:

#top-level-template1.jinja.schema
imports:
- path: sub-template.jinja

Then in my top level template I have this:

# top-level-template1.jinja
resources:
  - name: myresource
    type: sub-template.jinja

I want create multiple top level templates that use the same sub template (top-level-template1.jinja, top-level-template2.jinja, top-level-template2.jinja, etc)

Do I seriously have to create a schema file for every one of those? Can I share the same schema between them somehow? I would feel stupid copying it a bunch of times and just giving it a different name

red888
  • 27,709
  • 55
  • 204
  • 392

1 Answers1

0

Although is only possible to import templates using schemas, a workaround can be using a configuration file to import all the templates needed, with the possibility to mix Jinja and Python templates.

# configuration.yaml

imports:
- path: template-a.jinja
- path: template-b.py

resources:
- name: some-name
  type: template-a.jinja
  properties:
    zone: us-central1-a

- name: another-name
  type: template-b.py
  properties:
    zone: us-east1-b

If this workaround doesn't suit your needs, maybe you can file a feature request to have this implemented.

yyyyahir
  • 2,262
  • 1
  • 5
  • 14
  • Im using jinja templates though not config files. you cant pass arguments to config files from the command line like you can with jinja templates (using `--properites`) – red888 Oct 15 '19 at 16:12
  • If this doesn't suit your specific needs, maybe is best to file the feature request to have it implemented. – yyyyahir Oct 15 '19 at 16:13