I have a trivial deployment manager configuration as I try to understand using references and outputs from templates. Note that all examples are overly-simplified just to demonstrate the problem; obviously in a final version much more would be dynamic.
My first file is a low-level template designed to create a bucket with a dynamic name:
file: bucket.jinja
{% set NAME = properties['name'] %}
resources:
- name: templated-{{ NAME }}
type: storage.v1.bucket
properties:
location: us-central1
kind: storage#bucket
storageClass: STANDARD
versioning:
enabled: false
outputs:
- name: outValue
value: out-{{ NAME }}
My second file is a higher-level template to control the deployment:
file config.yaml
imports:
- path: bucket.jinja
resources:
- name: softcoded-1
type: bucket.jinja
properties:
name: testbucket
- name: hardcoded-$(ref.softcoded-1.outValue)
type: storage.v1.bucket
properties:
location: us-central1
kind: storage#bucket
storageClass: STANDARD
versioning:
enabled: false
- name: softcoded-2
type: bucket.jinja
properties:
name: noref
metadata:
dependsOn:
- softcoded-1
- name: softcoded-3
type: bucket.jinja
properties:
name: $(ref.softcoded-1.outValue)
metadata:
dependsOn:
- softcoded-1
When I try to run this, I get the following error:
% gcloud --project myproject deployment-manager deployments update test-deploy --config config.yaml --preview
The fingerprint of the deployment is b'5Hesgz1ujBJIotnjwJHJsg=='
Waiting for update [operation-1709425554385-612b6a6f06adf-8d791850-cffb5f4a]...failed.
ERROR: (gcloud.deployment-manager.deployments.update) Error in Operation [operation-1709425554385-612b6a6f06adf-8d791850-cffb5f4a]: errors:
- code: CONDITION_NOT_MET
message: Referenced resource softcoded-1 could not be found. In 'finalValue' section
of 'outputs' in the manifest layout.
However, if I remove the softcoded-3
resource, everything deploys as expected:
gcloud --project myproject deployment-manager deployments update test-deploy --config config.yaml --preview
The fingerprint of the deployment is b'mBk3HFf8zrIx1QQu0qEX9w=='
Waiting for update [operation-1709425600759-612b6a9b406a3-1d4b478a-b4f12123]...done.
Update operation operation-1709425600759-612b6a9b406a3-1d4b478a-b4f12123 completed successfully.
NAME TYPE STATE ERRORS INTENT
hardcoded-out-testbucket storage.v1.bucket IN_PREVIEW [] CREATE_OR_ACQUIRE
templated-noref storage.v1.bucket IN_PREVIEW [] CREATE_OR_ACQUIRE
templated-testbucket storage.v1.bucket IN_PREVIEW [] CREATE_OR_ACQUIRE
If I restore the softcoded-3
resource, I would expect an additional bucket to be created with the resolved name templated-out-testbucket
.
This seems to be in direct conflict with this example in Google's own docs, which shows a template outputting a value and the calling template then consuming that value as a property on another resource.
What am I missing in order to make this create the softcoded-3
resource without errors?
softcoded-2
andsoftcoded-3
is the use of the reference, and the reference (exactly the same) is used successfully inhardcoded-3
but just on the top-levelname
property of the resource instead of on theproperties.name
nested property.softcoded-3.metadata.dependsOn.softcoded-1
lines above... is there a different way to indicate this dependence?hardcoded-1
to show that the dependency is properly handled when the reference is part of the name of the resource; the only difference betweenhardcoded-1
andsoftcoded-3
with respect to the reference is that insoftcoded-3
the reference is not in the top-levelname
property but rather in a nested property further within the object, yethardcoded-1
works correctly (even with nodependsOn
reference, whilesoftcoded-3
does not at all work as expected or documented. The example in the link from Google's docs shows exactly the outcome I expect but am not seeing.