3
votes

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 dont want to have to resort to wrapping my configs with a makefile :(

1
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
if i try to use --config with --properties it tells me --properties can only be used against a templatered888
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-valuePatrick W

1 Answers

-1
votes

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