diff --git a/app/main.py b/app/main.py index 5068cfdf..b4453021 100644 --- a/app/main.py +++ b/app/main.py @@ -6,4 +6,5 @@ from app.routes.docker import * from app.routes.jenkins import * from app.routes.gitlab import * -from app.routes.grafana_data_sources import * \ No newline at end of file +from app.routes.grafana_data_sources import * +from app.routes.grafana_terraform import * \ No newline at end of file diff --git a/app/media/terraform.tfvars b/app/media/terraform.tfvars new file mode 100644 index 00000000..4e29150c --- /dev/null +++ b/app/media/terraform.tfvars @@ -0,0 +1,103 @@ + +# Grafana Connection Variables +grafana_connection = { + "url" = "http://localhost:8080", + "auth" = "" +} + + + +# Grafana_Contact_Point Variables +create_contact_point = true +contact_point_name = "My Contact Point" +use_email = false +use_slack = true +email_contact_point = { + addresses = ["one@company.org", "two@company.org"] + message = "{ len .Alerts.Firing } firing." + subject = "{{ template \"default.title\" .}}" + single_email = true + disable_resolve_message = false +} + +slack_contact_point = { + url = "https://hooks.slack.com/" + text = < Output: + + dir = 'app/media/terraform.tfvars' + + file_response = grafana_tfvars(request) + with open(dir,'w')as f: + f.write(file_response) + + return FileResponse(dir, media_type='application/zip', filename=f"terraform.tfvars") + \ No newline at end of file diff --git a/app/template_generators/terraform/tfvars/grafana.py b/app/template_generators/terraform/tfvars/grafana.py new file mode 100644 index 00000000..dff6bc1c --- /dev/null +++ b/app/template_generators/terraform/tfvars/grafana.py @@ -0,0 +1,170 @@ + + +def grafana_tfvars(input): + + grafana_connection = """{ + "url" = "http://localhost:8080", + "auth" = "" +} + """ + slack_contact_point = """{ + url = "https://hooks.slack.com/" + text = <