Create a Compute Engine VM instance using the Compute Engine API connector

Calls the Compute Engine API connector to create a Compute Engine VM instance based on specifications collected through Google Forms.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

  main 
 : 
  
 params 
 : 
  
 [ 
 input 
 ] 
  
 steps 
 : 
  
 - 
  
 init 
 : 
  
 assign 
 : 
  
 - 
  
 projectId 
 : 
  
 ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} 
  
 - 
  
 zone 
 : 
  
 ${input.zone} 
  
 - 
  
 machineType 
 : 
  
 ${input.machineType} 
  
 - 
  
 diskSize 
 : 
  
 ${input.diskSize} 
  
 - 
  
 imageProject 
 : 
  
 ${input.imageProject} 
  
 - 
  
 imageFamily 
 : 
  
 ${input.imageFamily} 
  
 - 
  
 vmName 
 : 
  
 ${input.vmName} 
  
 - 
  
 email 
 : 
  
 ${input.email} 
  
 - 
  
 createResource 
 : 
  
 call 
 : 
  
 googleapis.compute.v1.instances.insert 
  
 args 
 : 
  
 project 
 : 
  
 ${projectId} 
  
 zone 
 : 
  
 ${zone} 
  
 body 
 : 
  
 name 
 : 
  
 ${vmName} 
  
 machineType 
 : 
  
 ${"projects/" + projectId + "/zones/" + zone + "/machineTypes/" + machineType} 
  
 disks 
 : 
  
 - 
  
 initializeParams 
 : 
  
 diskSizeGb 
 : 
  
 ${diskSize} 
  
 sourceImage 
 : 
  
 ${"projects/" + imageProject + "/global/images/family/" + imageFamily} 
  
 type 
 : 
  
 PERSISTENT 
  
 boot 
 : 
  
 true 
  
 autoDelete 
 : 
  
 true 
  
 networkInterfaces 
 : 
  
 - 
  
 network 
 : 
  
 "global/networks/default" 
  
 result 
 : 
  
 insertResult 
  
 - 
  
 retStep 
 : 
  
 return 
 : 
  
 ${insertResult} 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: