Created
March 15, 2019 16:35
-
-
Save jpedro/f5bf3f0a40ad97aa00324352c5786528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import hcl | |
import os | |
import fnmatch | |
def checkHcl(file): | |
# print "==> CHECKING %s" % file | |
with open(file, "r") as f: | |
try: | |
obj = hcl.load(f) | |
except: | |
# print "--> NO HCL in %s" % file | |
return | |
res = obj.get("resource") | |
if not res: | |
# print "--> NO RESOURCES in %s" % file | |
return | |
sqls = res.get("google_sql_database_instance") | |
if not sqls: | |
# print "--> NO SQL in %s" % file | |
return | |
for name, spec in sqls.iteritems(): | |
# Dont rescue. Let it break if theres no backup | |
enabled = spec["settings"]["backup_configuration"]["enabled"] | |
print "==> FILE %s" % file | |
print " NAME %s" % name | |
print " ENABLED %s" % enabled | |
for root, dir, files in os.walk("gcp"): | |
for items in fnmatch.filter(files, "*.tf"): | |
file = root + "/" + items | |
checkHcl(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment