4

https://cloud.google.com/deployment-manager/docs/configuration/templates/define-template-properties

--properties is only supported for Jinja templates:

gcloud deployment-manager deployments create a-single-vm --template vm_template.jinja \
    --properties zone:us-central1-a

How do I pass properties to Python templates the same way with --config?

Edit

More info about my use case. I have a top level yaml config that pulls in multiple templates and sets properties. I can just create separate top level configs for dev and prod deployments with diff values for those environments but it would be nice to set these via command line.

Also I may need to dynamically change some of these params at deploy time in my deployment automation- for example when users click a button to deploy they are given the option to set some params to change. Is there any native support for transforming configs? I don't want to have to resort to wrapping my configs with a makefile.

halfer
  • 19,824
  • 17
  • 99
  • 186
red888
  • 27,709
  • 55
  • 204
  • 392
  • The flag should work with python as well, the variable in the python script needs to be defined to pull from `context.properties['variable']` and it should work, are you getting an error when you try? – Patrick W Oct 10 '19 at 15:16
  • 1
    if i try to use `--config` with `--properties` it tells me `--properties` can only be used against a template – red888 Oct 10 '19 at 16:07
  • that's correct. You want to use the `--template` flag and specify your `template.py`. Within the template, there should be variables that use `context.properties['varialble']` so when you do `--properties variable:new-value` the variable in the template will be replaced with new-value – Patrick W Oct 10 '19 at 16:11

1 Answers1

-1

Yes, you can use python template using multiple templates in Cloud Deployment Manager. Have a look at the link for detail configuration.

Nazmul Haque
  • 125
  • 1
  • 5