google-deployment-managerwurfl

How do I override Deployment package defaults in GCP Deployment Manager?


I would like to create an instance of WURFL Microservice Basic from the GCP Marketplace however I'd like to do that programatically so that I can reproduce it if required.

I downloaded the deployment zip file from the above linked page: enter image description here

and unzipped it onto my machine, so here I have the code for creating the WURFL solution:

enter image description here

The file test_config.yaml contains pertinent information about my deployment, I changed the zone to the zone that I want to deploy to:

imports:
- path: wurfl-microservice-basic.jinja

resources:
- name: wurfl-microservice-basic
  type: wurfl-microservice-basic.jinja
  properties:
    zone: europe-west2-a

Now I try and deploy using command:

gcloud deployment-manager deployments create \
  wurfl \
  --project xxxxxxx \
  --config test_config.yaml

which fails with error:

The fingerprint of the deployment is b'EciU4ogM5bd10ff_MnHsVQ==' Waiting for create [operation-1632242107865-5cc83fb06da45-f22cec62-c9ce6955]...failed.

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1632242107865-5cc83fb06da45-f22cec62-c9ce6955]: errors:

  • code: RESOURCE_ERROR location: /deployments/wurfl/resources/wurfl-vm message: "{"ResourceType":"compute.v1.instance","ResourceErrorCode":"400"
    ,"ResourceErrorMessage":{"code":400,"errors":[{"domain":"global","
    message":"Invalid value for field 'resource.networkInterfaces[0].network': 'https://www.googleapis.com/compute/v1/projects/xxxxxxx/global/networks/default'.
    \ The referenced network resource cannot be found.","reason":"invalid"}],"
    message":"Invalid value for field 'resource.networkInterfaces[0].network': 'https://www.googleapis.com/compute/v1/projects/xxxxxxx/global/networks/default'.
    \ The referenced network resource cannot be found.","statusMessage":"Bad Request"
    ,"requestPath":"https://compute.googleapis.com/compute/v1/projects/xxxxxxx/zones/europe-west2-a/instances"
    ,"httpMethod":"POST"}}"

(Notice in the last line that it correctly refers to europe-west2 as per my change)

The error makes sense, this project does not have a default network, it has an alternate network that I created and I'd like to override the default setting for network but I can't figure out how.

In vm_instance.py.schema I can see that networks are defined in a yaml list like so:

  networks:
    description: List of Networks for each network interface of this VM
    type: array
    default:
    - default

So I tried changing the networks in a similar way to where I set the zone:

imports:
- path: wurfl-microservice-basic.jinja

resources:
- name: wurfl-microservice-basic
  type: wurfl-microservice-basic.jinja
  properties:
    zone: europe-west2-a
    networks:
      - mynetwork

but that resulted in the same error. I also tried modifying vm_instance.py.schema with the correct network name but that didn't have any affect either.

Please can someone tell me how I can override a default (in this case the network) so that I can deploy this?


Solution

  • I figured it out, this is what was required

    imports:
    - path: wurfl-microservice-basic.jinja
    
    resources:
    - name: wurfl-microservice-basic
      type: wurfl-microservice-basic.jinja
      properties:
        zone: europe-west2-a
        network: mynetwork
        subnetwork: mysubnetwork