Created
February 15, 2020 20:29
-
-
Save glacion/5026077fe60084f00ada64a09dfbfcb7 to your computer and use it in GitHub Desktop.
Setup an ubuntu server with http and https access on GCP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Exit when any command fails | |
set -e | |
function log() { | |
echo "$(tput setaf 2)==> $(tput setaf 7)$@" | |
} | |
log 'Checking for SSH key.' | |
if [ ! -f ~/.ssh/id_rsa ] | |
then | |
log 'Creating SSH Key.' | |
ssh-keygen -N "" ~/.ssh/id_rsa | |
else | |
log 'SSH key found.' | |
fi | |
log 'Creating HTTP rule.' | |
gcloud compute firewall-rules create \ | |
default-allow-http \ | |
--direction=INGRESS \ | |
--priority=1000 \ | |
--network=default \ | |
--action=ALLOW \ | |
--rules=tcp:80 \ | |
--source-ranges=0.0.0.0/0 \ | |
--target-tags=http-server | |
log 'Creating HTTPS rule.' | |
gcloud compute firewall-rules create \ | |
default-allow-https \ | |
--direction=INGRESS \ | |
--priority=1000 \ | |
--network=default \ | |
--action=ALLOW \ | |
--rules=tcp:443 \ | |
--source-ranges=0.0.0.0/0 \ | |
--target-tags=https-server | |
log 'Creating instance.' | |
gcloud compute instances create \ | |
zarupa \ | |
--tags=http-server,https-server \ | |
--image-family=ubuntu-1804-lts \ | |
--image-project=ubuntu-os-cloud \ | |
--hostname=zarupa.internal | |
log 'Configuring SSH.' | |
gcloud compute config-ssh --ssh-key-file=~/.ssh/id_rsa | |
colorful logs as javascript nerds ;__;
inb4 the update where every message is including at least 69 emojis.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
colorful logs as javascript nerds ;__;