Skip to content

Instantly share code, notes, and snippets.

@constantlycoding
Last active July 3, 2019 08:41
Show Gist options
  • Select an option

  • Save constantlycoding/edc6118c18c9af25d4c4c8fe603d07fe to your computer and use it in GitHub Desktop.

Select an option

Save constantlycoding/edc6118c18c9af25d4c4c8fe603d07fe to your computer and use it in GitHub Desktop.
Configure a firewall and a startup script with Deployment Manager
#!/bin/bash
apt-get update
resources:
- type: compute.v1.instance
name: vm-test
properties:
zone: {{ properties["zone"] }}
machineType: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/zones/{{ properties["zone"] }}/machineTypes/f1-micro
# For examples on how to use startup scripts on an instance, see:
# https://cloud.google.com/compute/docs/startupscript
tags:
items: ["http","http-server"]
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
diskName: disk-{{ env["deployment"] }}
sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/global/networks/default
# Access Config required to give the instance a public IP address
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
metadata:
items:
- key: startup-script
value: |
{{ imports["install-web.sh"]|indent(10) }}
- type: compute.v1.firewall
name: fw-test
properties:
targetTags: ["http"]
network: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/global/networks/default
sourceRanges: ["0.0.0.0/0"]
allowed:
- IPProtocol: TCP
ports: ["80"]
imports:
- path: ql.jinja
- path: install-web.sh
name: install-web.sh
resources:
- name: qwiklabs
type: ql.jinja
properties:
zone: us-central1-a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment