From a4434fb845ff7a726d87b8e1226f445f401f383d Mon Sep 17 00:00:00 2001 From: Guillaume Charest <1690085+gcharest@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:58:26 +0000 Subject: [PATCH] feat: Add AWS Dev module for testing AWS integrations service (will be removed) --- app/modules/dev/aws_dev.py | 23 +++++++++++++++++++++++ app/modules/sre/sre.py | 7 +++++++ 2 files changed, 30 insertions(+) create mode 100644 app/modules/dev/aws_dev.py diff --git a/app/modules/dev/aws_dev.py b/app/modules/dev/aws_dev.py new file mode 100644 index 00000000..e3cf4c88 --- /dev/null +++ b/app/modules/dev/aws_dev.py @@ -0,0 +1,23 @@ +"""Testing AWS service (will be removed)""" +import os + +from integrations.aws import identity_store, client as aws_client +from dotenv import load_dotenv + +load_dotenv() + + +def aws_dev_command(client, body, respond): + groups = identity_store.list_groups() + if not groups: + respond("There was an error retrieving the groups.") + return + respond(f"Found {len(groups)} groups.") + for k, v in groups[0].items(): + print(f"{k}: {v}") + + users = identity_store.list_users() + if not users: + respond("There was an error retrieving the users.") + return + respond(f"Found {len(users)} users.") diff --git a/app/modules/sre/sre.py b/app/modules/sre/sre.py index 70afb347..c12dc743 100644 --- a/app/modules/sre/sre.py +++ b/app/modules/sre/sre.py @@ -8,6 +8,7 @@ from modules.incident import incident_helper from modules import google_service from modules.sre import geolocate_helper, webhook_helper +from modules.dev import aws_dev from integrations.slack import commands as slack_commands help_text = """ @@ -65,6 +66,12 @@ def sre_command(ack, command, logger, respond, client, body): else: respond("This command is only available in the dev environment.") return + case "aws": + if PREFIX == "dev-": + aws_dev.aws_dev_command(client, body, respond) + else: + respond("This command is only available in the dev environment.") + return case _: respond( f"Unknown command: `{action}`. Type `/sre help` to see a list of commands. \nCommande inconnue: `{action}`. Entrez `/sre help` pour une liste des commandes valides"