Skip to content

Instantly share code, notes, and snippets.

@chriskyfung
Last active March 26, 2020 02:01
Show Gist options
  • Save chriskyfung/245e0eb142df08d97f42717ea188be72 to your computer and use it in GitHub Desktop.
Save chriskyfung/245e0eb142df08d97f42717ea188be72 to your computer and use it in GitHub Desktop.
Deployment Template for Configure a Firewall and a Startup Script with Deployment Manager
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
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
accessConfigs:
- name: External NAT
type: ONE_TO_ONE_NAT
metadata:
items:
- key: startup-script
value: |
#!/bin/bash
apt-get update
apt-get install -y apache2
tags:
items:
- http
serviceAccounts:
- email: <YOUR-SERVICE-ACCOUNT-EMAIL>
scopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring.write
- https://www.googleapis.com/auth/servicecontrol
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/trace.append
- type: compute.v1.firewall
name: default-allow-http
properties:
network: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/global/networks/default
targetTags:
- http
allowed:
- IPProtocol: tcp
ports:
- '80'
sourceRanges:
- 0.0.0.0/0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment