-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy path05-tags.sh
executable file
·102 lines (81 loc) · 2.62 KB
/
05-tags.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# Make sure that variables are updated
source ./$VAR_FILE
# We will be using these tags to mark all of the deployments with project/Environment pairs
# ONLY execute ONCE the creation and adding of values
# Some variables are referenced in the 02-variables.sh script
az tag create --name Environment
az tag create --name Project
az tag create --name Department
az tag create --name Status
az tag add-value \
--name Environment \
--value DEV
az tag add-value \
--name Environment \
--value STG
az tag add-value \
--name Environment \
--value QA
az tag add-value \
--name Environment \
--value PROD
az tag add-value \
--name Environment \
--value DR-PROD
az tag add-value \
--name Project \
--value $PROJECT_CODE
az tag add-value \
--name Project \
--value Shared-Service
az tag add-value \
--name Department \
--value IT
az tag add-value \
--name Status \
--value Experimental
az tag add-value \
--name Status \
--value PILOT
az tag add-value \
--name Status \
--value Approved
# Saving the key/value pairs into variables
# This is only a reference, the tags savings to variables happen in the 02-variables.sh if you need to update it
# echo export TAG_ENV_DEV="Environment=DEV" >> ./$VAR_FILE
# echo export TAG_ENV_STG="Environment=STG" >> ./$VAR_FILE
# echo export TAG_ENV_QA="Environment=QA" >> ./$VAR_FILE
# echo export TAG_ENV_PROD="Environment=PROD" >> ./$VAR_FILE
# echo export TAG_ENV_DR_PROD="Environment=DR-PROD" >> ./$VAR_FILE
# echo export TAG_PROJ_CODE="Project=${PROJECT_CODE}" >> ./$VAR_FILE
# echo export TAG_PROJ_SHARED="Project=Shared-Service" >> ./$VAR_FILE
# echo export TAG_DEPT_IT="Department=IT" >> ./$VAR_FILE
# echo export TAG_STATUS_EXP="Status=Experimental" >> ./$VAR_FILE
# echo export TAG_STATUS_PILOT="Status=PILOT" >> ./$VAR_FILE
# echo export TAG_STATUS_APPROVED="Status=APPROVED" >> ./$VAR_FILE
# This is created at the level of the subscription. So we will append --tags 'key1=value1 key2=value2'
# Tagging can help in setting up policies, cost management and other scenarios.
case "$ENVIRONMENT" in
"stg")
echo export "TAG_ENV=\"$TAG_ENV_STG\"" >> ./$VAR_FILE
;;
"qa")
echo export "TAG_ENV=\"$TAG_ENV_QA\"" >> ./$VAR_FILE
;;
"prod")
echo export "TAG_ENV=\"$TAG_ENV_PROD\"" >> ./$VAR_FILE
;;
"dr-prod")
echo export "TAG_ENV=\"$TAG_ENV_DR_PROD\"" >> ./$VAR_FILE
;;
"dev")
echo "export TAG_ENV=\"$TAG_ENV_DEV\"" >> ./$VAR_FILE
;;
*)
echo "Error: Unknown environment $ENVIRONMENT"
exit 1
;;
esac
source ./$VAR_FILE
echo "Tags Creation Completed"