Plan examples workflow (#53)

Co-authored-by: Bonthu <vabonthu@c889f3b8acd3.ant.amazon.com>
This commit is contained in:
Vara Bonthu
2022-10-21 06:09:17 +01:00
committed by GitHub
parent 46ffad7bd2
commit 0949f5d720
4 changed files with 168 additions and 22 deletions
+25
View File
@@ -0,0 +1,25 @@
import json
import glob
import re
def get_examples():
"""
Get all Terraform example root directories using their respective `versions.tf`;
returning a string formatted json array of the example directories minus those that are excluded
"""
exclude = {
'', # Add examples here to exclude from terraform plan
}
projects = {
x.replace('/versions.tf', '')
for x in glob.glob('examples/**/versions.tf', recursive=True)
if not re.match(r'^.+/_', x)
}
print(json.dumps(list(projects.difference(exclude))))
if __name__ == '__main__':
get_examples()