Skip to content

Commit 377c5dd

Browse files
committed
Merge branch 'mr/trespeuch/role-ref' into 'master'
Add ref property to IAM role See merge request it/e3-aws!85
2 parents 254952f + 8122a9f commit 377c5dd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/e3/aws/troposphere/iam/role.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from __future__ import annotations
44
from dataclasses import dataclass, field
5+
from functools import cached_property
56
from typing import TYPE_CHECKING
67

7-
from troposphere import AWSObject, iam, Tags, GetAtt
8+
from troposphere import AWSObject, iam, Tags, GetAtt, Ref
89

910
from e3.aws import name_to_id
1011
from e3.aws.troposphere import Construct
@@ -93,6 +94,11 @@ def policies(self) -> list[iam.Policy] | None:
9394
def arn(self):
9495
return GetAtt(name_to_id(self.name), "Arn")
9596

97+
@cached_property
98+
def ref(self) -> Ref:
99+
"""Return a Ref on the role, the Ref on an iam Role returns its name."""
100+
return Ref(name_to_id(self.name))
101+
96102
def resources(self, stack: Stack) -> list[AWSObject]:
97103
"""Return troposphere objects defining the role."""
98104
attr = {}

0 commit comments

Comments
 (0)