Skip to content

Commit cf28df8

Browse files
committed
Add ManagedPolicyARNs to Lambda Scaler
1 parent ecd88d3 commit cf28df8

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

template.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ Parameters:
105105
Description: The ARN of the policy used to set the permissions boundary for the role.
106106
Default: ""
107107

108+
ManagedPolicyARNs:
109+
Type: CommaDelimitedList
110+
Description: Optional - Comma separated list of managed IAM policy ARNs to attach to the Lambda execution role.
111+
Default: ""
112+
108113
LogRetentionDays:
109114
Type: Number
110115
Description: The number of days to retain the Cloudwatch Logs of the lambda.
@@ -138,8 +143,9 @@ Parameters:
138143
- "false"
139144
Default: "false"
140145

141-
142146
Conditions:
147+
HasManagedPolicyARNs:
148+
!Not [ !Equals [ !Join [ "", !Ref ManagedPolicyARNs ], "" ] ]
143149
CreateRole:
144150
!Equals [ !Ref AutoscalingLambdaExecutionRole, '' ]
145151
UseKmsKeyForParameterStore:
@@ -202,8 +208,15 @@ Resources:
202208
- lambda.amazonaws.com
203209
Action:
204210
- sts:AssumeRole
205-
ManagedPolicyArns:
206-
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
211+
ManagedPolicyArns: !If
212+
- HasManagedPolicyARNs
213+
- !Split
214+
- ','
215+
- !Join
216+
- ','
217+
- - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
218+
- !Join [ ',', !Ref ManagedPolicyARNs ]
219+
- - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
207220
Policies:
208221
- PolicyName: AutoScalingGroups
209222
PolicyDocument:

0 commit comments

Comments
 (0)