@@ -91,6 +91,10 @@ class AutoscalingFargateCluster(tb_pulumi.ThunderbirdComponentResource):
9191 the only valid source. Defaults to {}.
9292 :type container_security_groups: _type_, optional
9393
94+ :param extra_policies: A dict where the keys are the names of services and the values are lists of ARNs of IAM
95+ Policies that service should operate with in addition to what is provided by using the ``registries``,
96+ ``secrets``, and ``ssm_params`` parameters.
97+
9498 :param listeners: A nested dict describing your load balancers' listeners and which targets they point to. At the
9599 top level, the keys are names of load balancers and the values are other dicts. Those dicts' keys are the names of
96100 targets, and their values are inputs to an `aws.lb.Listener
@@ -169,6 +173,7 @@ def __init__(
169173 cluster : dict = {},
170174 cluster_name : str = None ,
171175 container_security_groups : dict [str :dict ] = {},
176+ extra_policies : dict [str :list ] = {},
172177 listeners : dict [str , dict ] = {},
173178 load_balancer_security_groups : dict [str , dict ] = {},
174179 load_balancers : dict = {},
@@ -275,21 +280,28 @@ def __init__(
275280 }
276281
277282 # Build the execution roles using the policies from above, if they exist
278- exec_roles = {
279- service : aws .iam .Role (
283+ exec_roles = {}
284+
285+ for service in services .keys ():
286+ _managed_policy_arns = [
287+ # This AWS managed policy allows access to ECR and log streams
288+ 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy' ,
289+ ]
290+ _managed_policy_arns += [
291+ item
292+ for item in [
293+ exec_role_policies [service ] if service in exec_role_policies else None ,
294+ ]
295+ if item is not None
296+ ]
297+ _managed_policy_arns += extra_policies .get (service , [])
298+
299+ exec_roles [service ] = aws .iam .Role (
280300 f'{ name } -execrole-{ service } ' ,
281301 name = f'{ name } -{ service } ' ,
282302 description = f'Task execution role for running the { service } service for { self .project .name_prefix } ' ,
283303 assume_role_policy = arp ,
284- managed_policy_arns = [
285- item
286- for item in [
287- # This AWS managed policy allows access to ECR and log streams
288- 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy' ,
289- exec_role_policies [service ] if service in exec_role_policies else None ,
290- ]
291- if item is not None
292- ],
304+ managed_policy_arns = _managed_policy_arns ,
293305 tags = self .tags ,
294306 opts = pulumi .ResourceOptions (
295307 parent = self ,
@@ -300,8 +312,6 @@ def __init__(
300312 ],
301313 ),
302314 )
303- for service in services .keys ()
304- }
305315
306316 # First we build out task definitions. Later, we can refer to them by name. Since task definitions are
307317 # one-to-one with cluster services, the task_name here is assumed to match with a service name.
0 commit comments