-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
63 lines (63 loc) · 1.98 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
PROJECT=dev-machine-352317
REGION=us-west1
INSTANCE=dev-machine-vm
IP_NAME=dev-machine-ip
FIREWALL_HTTP=allow-http
FIREWALL_HTTPS=allow-https
TAG_HTTP=http-server
TAG_HTTPS=https-server
create_ip:
gcloud compute addresses create ${IP_NAME} \
--project=${PROJECT} \
--network-tier=STANDARD \
--region=${REGION}
export_ip:
$(eval IP_ADDRESS:=$(shell gcloud compute addresses list \
--filter="name:dev-machine-ip AND region:us-west1" \
--format="value(address_range())"))
show_ip:
@echo ${IP_ADDRESS}
firewall_http:
gcloud compute firewall-rules create ${FIREWALL_HTTP} \
--project=${PROJECT} \
--direction=INGRESS \
--network=default \
--action=ALLOW \
--rules=tcp:80 \
--source-ranges=0.0.0.0/0 \
--target-tags=${TAG_HTTP}
firewall_https:
gcloud compute firewall-rules create ${FIREWALL_HTTPS} \
--project=${PROJECT} \
--direction=INGRESS \
--network=default \
--action=ALLOW \
--rules=tcp:443 \
--source-ranges=0.0.0.0/0 \
--target-tags=${TAG_HTTPS}
create_instance: export_ip
gcloud compute instances create ${INSTANCE} \
--scopes=cloud-platform \
--project=${PROJECT} \
--zone=${REGION}-b \
--machine-type=n1-standard-1 \
--preemptible \
--image=ubuntu-1804-bionic-v20220530 \
--image-project=ubuntu-os-cloud \
--boot-disk-size=10GB \
--boot-disk-type=pd-standard \
--boot-disk-device-name=${INSTANCE} \
--metadata-from-file startup-script=vm/dev-machine.sh \
--network-tier=STANDARD \
--address=${IP_ADDRESS} \
--subnet=default \
--tags=${TAG_HTTP},${TAG_HTTPS} \
--labels=os=ubuntu-18-04-lts,cost-alloc=${INSTANCE},usage=development,configuration=v1-1-0
run: create_ip export_ip firewall_http firewall_https create_instance
ssh:
gcloud compute ssh --zone "${REGION}-b" "${INSTANCE}" --project "${PROJECT}"
cleanup:
gcloud --quiet compute instances delete ${INSTANCE} --zone=${REGION}-b
gcloud --quiet compute addresses delete ${IP_NAME} --region=${REGION}
gcloud --quiet compute firewall-rules delete ${FIREWALL_HTTP}
gcloud --quiet compute firewall-rules delete ${FIREWALL_HTTPS}