Deployment Manager in GCP automates the creation and management of Google Cloud resources. With Deployment Manager Python or Jinja2 templates can be used for parametrization.
mkdir test-vm
cd test-vm
nano vm-config.yaml
imports:
- path: vm.jinja
resources:
- name: test-instance
type: vm.jinja
properties:
zone: us-central1-f
machineType: f1-micro
nano vm.jinja
resources:
- type: compute.v1.instance
name: {{ env["deployment"] }}-instance
properties:
machineType: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/zones/{{ properties["zone"] }}/machineTypes/{{ properties["machineType"] }}
zone: {{ properties["zone"] }}
networkInterfaces:
- subnetwork: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/regions/us-central1/subnetworks/default
disks:
- deviceName: boot
type: PERSISTENT
boot: true
initializeParams:
sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
gcloud deployment-manager deployments create testinfra --config=vm-config.yaml
Create operation operation-1587****862-5a*******ad104-bacbcabb-7*****bc completed successfully.
NAME TYPE STATE ERRORS INTENT
testinfra-instance compute.v1.instance COMPLETED []
Category: GCP