0

How can I deploy a computer instance with no public IP using GCP Deployment Manager?

Looking at the yaml configuration file, I get an error if I don't include anything in accessConfigs. networkInterfaces is also mandatory. At the moment my configuration file for the resource looks like this:

- type: compute.v1.instance                                                                      
  name: cassandra-node-1                                                                           
  properties:                                                                                        
    zone: europe-west2-c                                                                             
    machineType: https://www.googleapis.com/compute/v1/projects/affable-seat-213016/zones/europe-west2-c/machineTypes/n1-standard-1                                                                   
    disks:                                                                                           
    - deviceName: boot                                                                                 
      boot: true                                                                                       
      autoDelete: true                                                                                 
      initializeParams:                                                                                  
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20181204                                                                        
      networkInterfaces:                                                                               
      - accessConfigs: 

I have tried several combinations of accessConfigs and networkInterfaces, but so far only the ones that work are the ones with the snippet below, but that assigns a public IP to the instance.

networkInterfaces:                                                                               
- accessConfigs:                                                                                  
   - name: External NAT                                                                               
     type: ONE_TO_ONE_NAT

EDIT
Deploying with no accessConfig gives error:

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-1545956660669-57e0a1598ea49-702a8e20-89ae5f53]: errors: - code: CONDITION_NOT_MET
location: /deployments/test/resources/cassandra-node-1->$.properties
message: '"/networkInterfaces": domain: validation; keyword: type; message: instance
does not match any allowed primitive type; allowed: ["array"]; found: "null"'

1 Answer 1

3

If you remove the accessConfigs member completely, as opposed to providing an empty accessConfigs, the instance is created without an external IP address.

5
  • Doesn't work. networkInterfaces doesn't accept a null value. If you try to deploy without the element it gives this error: message: '"/networkInterfaces": domain: validation; keyword: type; message: instance does not match any allowed primitive type; allowed: ["array"]; found: "null"' Commented Dec 28, 2018 at 0:26
  • Yes, you still need to provide at least a network. It's the accessConfigs portion that you should remove completely.
    – Zach Seils
    Commented Dec 28, 2018 at 4:19
  • 1
    Example: resources: - name: the-first-vm type: compute.v1.instance properties: zone: us-central1-f machineType: https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-f/machineTypes/f1-micro disks: - deviceName: boot type: PERSISTENT boot: true autoDelete: true initializeParams: sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9 networkInterfaces: - network: https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default
    – Zach Seils
    Commented Dec 28, 2018 at 4:24
  • I didn't include the network, because as per the docs, it would use the default network. It seems a bit silly that we need to include a default value, just so DM accepts the yaml file. Thanks! Commented Dec 28, 2018 at 19:22
  • 1
    Ah, I see. I have opened a bug internally and will follow up here when I have an update. Thanks.
    – Zach Seils
    Commented Jan 2, 2019 at 21:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.