Skip to content

Instantly share code, notes, and snippets.

@obernardocosta
Last active October 13, 2019 20:55
Show Gist options
  • Save obernardocosta/bfde7f05c3ab68d3e68b35472fb58cf4 to your computer and use it in GitHub Desktop.
Save obernardocosta/bfde7f05c3ab68d3e68b35472fb58cf4 to your computer and use it in GitHub Desktop.
Configure a Firewall and a Startup Script with Deployment Manager
# first download the repository
#$ mkdir deployment_manager
#$ cd deployment_manager
#$ gsutil cp gs://spls/gsp302/* .
# change qwiklabs.jinja to this file
resources:
- name: default-allow-http
type: compute.v1.firewall
properties:
targetTags: ["http"]
sourceRanges: ["0.0.0.0/0"]
allowed:
- IPProtocol: TCP
ports: ["80"]
- 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
tags:
items: ["http"]
metadata:
items:
- key: startup-script
value: "apt-get update \n apt-get install -y apache2"
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
gcloud deployment-manager deployments create deployment-templates --config qwiklabs.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment