Skip to content

Commit

Permalink
Add method to build App IAM role arn
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljcollinsuk committed Feb 9, 2024
1 parent ceb25e2 commit f991c59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controlpanel/api/models/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
5 changes: 5 additions & 0 deletions tests/api/models/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit f991c59

Please sign in to comment.