From f991c59aba116f49d11b9a2764fb8036b8256c0d Mon Sep 17 00:00:00 2001 From: Michael Collins <15347726+michaeljcollinsuk@users.noreply.github.com> Date: Fri, 9 Feb 2024 16:31:32 +0000 Subject: [PATCH] Add method to build App IAM role arn --- controlpanel/api/models/app.py | 4 ++++ tests/api/models/test_app.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/controlpanel/api/models/app.py b/controlpanel/api/models/app.py index 88359206f..288d53811 100644 --- a/controlpanel/api/models/app.py +++ b/controlpanel/api/models/app.py @@ -79,6 +79,10 @@ def _repo_name(self): def release_name(self): return webapp_release_name(self._repo_name) + @property + def iam_role_arn(self): + return cluster.iam_arn(f"role/{self.iam_role_name}") + def get_group_id(self, env_name): return self.get_auth_client(env_name).get("group_id") diff --git a/tests/api/models/test_app.py b/tests/api/models/test_app.py index 3d81825ff..c9132c5b0 100644 --- a/tests/api/models/test_app.py +++ b/tests/api/models/test_app.py @@ -204,3 +204,8 @@ def test_app_allowed_ip_ranges(): full_app_ip_ranges = app.app_allowed_ip_ranges assert " " not in full_app_ip_ranges assert len(full_app_ip_ranges.split(",")) == 4 + + +def test_iam_role_arn(): + app = App(slug="example-app") + assert app.iam_role_arn == f"arn:aws:iam::{settings.AWS_DATA_ACCOUNT_ID}:role/test_app_example-app"