-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprovider.sh
39 lines (28 loc) · 818 Bytes
/
provider.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
#!/bin/bash
AWK="${PWD}/provider.awk"
TYPE=$1
function listDetails {
for i in $(find . -name "*.tf" -execdir sh -c 'pwd' sh {} + | sort | uniq); do
cd "$i" || exit
printf '\n\\%s\n' "${PWD##*/} contains:"
find . -maxdepth 1 -name "*.tf" -exec awk -f "$AWK" {} +
done
}
function listUniq {
find . -name "*.tf" -exec awk -f "$AWK" {} + | sort | uniq -c
}
function listAll {
find . -name "*.tf" -exec awk -f "$AWK" {} +
}
function listTypes {
find . -name "*.tf" -exec awk '/^resource[[:space:]]+"/ { gsub("\"",""); print $2 }' {} + | awk -F_ '{ print $1 }' | sort | uniq
}
if [[ $TYPE == "details" ]]; then
listDetails
elif [[ $TYPE == "uniq" ]]; then
listUniq
elif [[ $TYPE == "all" ]]; then
listAll
elif [[ $TYPE == "types" ]]; then
listTypes
fi