Skip to content

Instantly share code, notes, and snippets.

@cgaete
Last active August 14, 2019 20:09
Show Gist options
  • Save cgaete/d097381df53a4d88378027c7ecaaf87d to your computer and use it in GitHub Desktop.
Save cgaete/d097381df53a4d88378027c7ecaaf87d to your computer and use it in GitHub Desktop.
Configure a Firewall and a Startup Script with Deployment Manager
resources:
- name: my-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: ${ZONE}
tags:
items: ["http"]
machineType: https://www.googleapis.com/compute/v1/projects/${PROJECT_ID}/zones/${ZONE}/machineTypes/f1-micro
# For examples on how to use startup scripts on an instance, see:
# https://cloud.google.com/compute/docs/startupscript
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
diskName: disk-${NAME}
sourceImage: https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/family/debian-9
networkInterfaces:
- network: https://www.googleapis.com/compute/v1/projects/${PROJECT_ID}/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: |
#!/bin/bash
sudo apt-get update && sudo apt-get install -y apache2
#ejecutar deploy in console
gcloud deployment-manager deployments create quickstart-deployment --config qwiklabs.yaml
#revisar deploy creado OPCIONAL
gcloud deployment-manager deployments describe quickstart-deployment
@cgaete
Copy link
Author

cgaete commented Apr 18, 2019

Crear script .yaml a partir de lo solicitado personalizando el PROJECT_ID, ZONE y todos los parámetros ${}. Una vez creado el script crear el deploy usando deployment-manager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment