Skip to content

Commit

Permalink
better typing for construct_target
Browse files Browse the repository at this point in the history
  • Loading branch information
sidhujus committed Oct 4, 2023
1 parent 8027f2f commit f5e0070
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions samtranslator/model/stepfunctions/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ def to_cloudformation(self, resource, **kwargs): # type: ignore[no-untyped-def]
events_rule.Name = self.Name
events_rule.Description = self.Description

role = self.RoleArn
role: Union[IAMRole, str]
if self.RoleArn is None:
role = self._construct_role(resource, permissions_boundary, prefix=None)
resources.append(role)
else:
role = self.RoleArn

source_arn = events_rule.get_runtime_attr("arn")
dlq_queue_arn = None
Expand All @@ -164,7 +166,7 @@ def to_cloudformation(self, resource, **kwargs): # type: ignore[no-untyped-def]
def _construct_target(
self,
resource: StepFunctionsStateMachine,
role: Union[IAMRole, Optional[PassThrough]],
role: Union[IAMRole, str],
dead_letter_queue_arn: Optional[str],
) -> Dict[str, Any]:
"""_summary_
Expand All @@ -180,7 +182,7 @@ def _construct_target(
Returns
-------
_description_
The Target property
"""
target_id = (
self.Target["Id"]
Expand All @@ -194,7 +196,7 @@ def _construct_target(
}

if role is not None:
target["RoleArn"] = role if isinstance(role, str) else role.get_runtime_attr("arn")
target["RoleArn"] = role.get_runtime_attr("arn") if isinstance(role, IAMRole) else role

if self.Input is not None:
target["Input"] = self.Input
Expand Down

0 comments on commit f5e0070

Please sign in to comment.