0

Is it possible to use a yaml array in --properties with gcloud deployment-manager?

I've tried something like:

gcloud deployment-manager deployments create my-deployment --template my-firewall.py --properties "ips:['127.0.0.1','127.0.0.2']"

And I get:

ERROR: (gcloud) Failed to parse YAML: while parsing a flow sequence
  in "<unicode string>", line 1, column 1:
    ['127.0.0.1'
    ^ (line: 1)
expected ',' or ']', but got '<stream end>'
  in "<unicode string>", line 1, column 13:
    ['127.0.0.1'
                ^ (line: 1)

It should be possible to do it with flow style on a single line, but I think the gcloud CLI splits the string on commas. I have not figured out a way to escape the comma.

ahong
  • 1,041
  • 2
  • 10
  • 22
  • It's curious that part of the error suggests it is expecting `]` (and thus potentially does accept collections). Could it be that it's being thrown by your use of `'`? What is the result with `"ips:[\"127.0.0.1\",\"127.0.0.2\"]"`? The documentation is unclear. It says value are YAML but does only describe strings, bools and integers https://cloud.google.com/deployment-manager/docs/configuration/templates/define-template-properties#templatepropertiescommandline – DazWilkin Jun 08 '20 at 21:00
  • 3
    You should be able to change the delimiter, as specified at https://cloud.google.com/sdk/gcloud/reference/topic/escaping. Perhaps `--properties "^--^ips:['127.0.0.1','127.0.0.2']"`, to ensure that the comma isn't interpreted as a separator? – Gerb Jun 09 '20 at 18:03
  • that is awesome! Didn't know about that feature. Could you add that as the answer and I'll accept it? I ran into another problem. I was using a config and not a template/composite-type so I had to fix that also. https://cloud.google.com/sdk/gcloud/reference/topic/flags-file is also interesting. – ahong Jun 10 '20 at 12:12

0 Answers0