0
votes

Take the following .yaml file:

imports:
- path: apis.py
resources:
- name: test-project
  type: cloudresourcemanager.v1.project
  properties:
    name: test-project
    projectId: test-project
    parent:
      type: folder
      id: ''
- name: billing_test-project
  type: deploymentmanager.v2.virtual.projectBillingInfo
  metadata:
    dependsOn:
    - test-project
  properties:
    name: projects/test-project
    billingAccountName: billingAccountName
- name: apis
  type: apis.py
  properties:
    project: test-project
    billing: billing_test-project
    apis:
    - compute.googleapis.com
    concurrent_api_activation: true
- name: set-export-bucket
  action: gcp-types/compute-v1:compute.projects.setUsageExportBucket
  properties:
    project: test-project
    bucketName: gs://export-bucket
    reportNamePrefix: usage_gce_
  metadata:
    dependsOn:
    - test-project
    - test-project-compute.googleapis.com

When using the GCP Deployment Manager API to POST this YAML, I receive the following error message:

"Invalid config files: Template fetching failed: Failed to find imported template 'apis.py' for resource {name=apis, properties={apis=[compute.googleapis.com], billing=billing_test-project, concurrent_api_activation=true, project=test-project}, type=apis.py}"

I've followed the documentation for creating a template (https://cloud.google.com/deployment-manager/docs/step-by-step-guide/create-a-template), and the 'apis.py' file has been taken from the project creation example: https://github.com/GoogleCloudPlatform/deploymentmanager-samples/tree/master/examples/v2/project_creation

I'm not really sure what I'm doing wrong here. I found another post where another user ran into a similar issue, but the answer was to use a schema: (Google Deploy Manager (Invalid config files: Template fetching failed / Failed to find resource)

However, I found a more recent post that said you don't need to specify a schema: Do GCP Deployment Manager templates require a schema file?

So, which is it? And if I do need to specify a schema, what does this look like using only .py files? (I don't have any .jinja files in my configuration at all.)

1

1 Answers

1
votes

It could require to have the path where you put the apis.py in your machine, specified on the YAML in order to find it.