-
Notifications
You must be signed in to change notification settings - Fork 4
/
deploy.sh
executable file
·77 lines (73 loc) · 2.54 KB
/
deploy.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
PROJECT_ID="$1"
# Set Project
gcloud config set project $PROJECT_ID
case "$3" in
"create" )
DEPLOY_ACTION="create"
;;
"delete" )
DEPLOY_ACTION="delete"
;;
* )
echo "Script requires an action. E.g. create, delete"
exit 1
;;
esac
case "$2" in
"iam" )
PROJECT_NUM=$(gcloud projects list \
--filter=PROJECT_ID=$PROJECT_ID \
--format="value(PROJECT_NUMBER)")
if [ "$DEPLOY_ACTION" = "create" ]; then
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$PROJECT_NUM@cloudservices.gserviceaccount.com \
--role roles/owner
else
echo "Deleting $PROJECT_ID-iam"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member serviceAccount:$PROJECT_NUM@cloudservices.gserviceaccount.com \
--role roles/owner
fi
;;
"network" )
if [ "$DEPLOY_ACTION" = "create" ]; then
gcloud deployment-manager deployments create $PROJECT_ID-network \
--config resources/network.yaml
else
echo "Deleting $PROJECT_ID-network"
gcloud deployment-manager deployments delete $PROJECT_ID-network -q
fi
;;
"cloud-router" )
if [ "$DEPLOY_ACTION" = "create" ]; then
gcloud deployment-manager deployments create $PROJECT_ID-cloud-router \
--config resources/cloud_router.yaml
else
echo "Deleting $PROJECT_ID-cloud-router"
gcloud deployment-manager deployments delete $PROJECT_ID-cloud-router -q
fi
;;
"gke" )
if [ "$DEPLOY_ACTION" = "create" ]; then
gcloud deployment-manager deployments create $PROJECT_ID-gke \
--config resources/gke.yaml
else
echo "Deleting $PROJECT_ID-gke"
gcloud deployment-manager deployments delete $PROJECT_ID-gke -q
fi
;;
"bastion" )
if [ "$DEPLOY_ACTION" = "create" ]; then
gcloud deployment-manager deployments create $PROJECT_ID-bastion \
--config resources/bastion.yaml
else
echo "Deleting $PROJECT_ID-bastion"
gcloud deployment-manager deployments delete $PROJECT_ID-bastion -q
fi
;;
* )
echo "Script requires a resource. E.g. iam, network, cloud-router, gke, bastion"
exit 1
;;
esac