Skip to content
This repository was archived by the owner on Jun 26, 2024. It is now read-only.

Commit 46b1023

Browse files
committed
update to IAM role for lambda custom resource to include new iam:passRole permission needed for Cognito API calls
1 parent 9050e71 commit 46b1023

1 file changed

Lines changed: 47 additions & 5 deletions

File tree

cloudformation/cognito-creation-helper.template

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
}
123123
},
124124

125-
"LambdaCognitoExecutionRole": {
125+
"LambdaCreateCognitoExecutionRole": {
126126
"Type": "AWS::IAM::Role",
127127
"Properties": {
128128
"AssumeRolePolicyDocument": {
@@ -158,6 +158,48 @@
158158
}
159159
},
160160

161+
"LambdaUpdateCognitoExecutionRole": {
162+
"Type": "AWS::IAM::Role",
163+
"Properties": {
164+
"AssumeRolePolicyDocument": {
165+
"Version": "2012-10-17",
166+
"Statement": [{
167+
"Effect": "Allow",
168+
"Principal": {"Service": ["lambda.amazonaws.com"]},
169+
"Action": ["sts:AssumeRole"]
170+
}]
171+
},
172+
"Path": "/",
173+
"Policies": [{
174+
"PolicyName": "root",
175+
"PolicyDocument": {
176+
"Version": "2012-10-17",
177+
"Statement": [{
178+
"Effect": "Allow",
179+
"Action": ["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],
180+
"Resource": "arn:aws:logs:*:*:*"
181+
},
182+
{
183+
"Effect": "Allow",
184+
"Action": ["cognito-identity:CreateIdentityPool","cognito-identity:SetIdentityPoolRoles","cognito-identity:UpdateIdentityPool"],
185+
"Resource": "*"
186+
},
187+
{
188+
"Effect": "Allow",
189+
"Action": ["iam:putRolePolicy"],
190+
"Resource": {"Ref": "LambdaUserRole"}
191+
},
192+
{
193+
"Effect": "Allow",
194+
"Action": ["iam:passRole"],
195+
"Resource": [{ "Fn::GetAtt" : ["CognitoServerlessBlogAuthenticatedRole", "Arn"] },
196+
{ "Fn::GetAtt" : ["CognitoServerlessBlogUnauthenticatedRole", "Arn"] }]
197+
}]
198+
}
199+
}]
200+
}
201+
},
202+
161203
"CreateCognitoPoolResource": {
162204
"Type": "Custom::CreateCognitoPoolResource",
163205
"Properties": {
@@ -175,12 +217,12 @@
175217
},
176218

177219
"AddCognitoIdentityPool": {
178-
"DependsOn": "LambdaCognitoExecutionRole",
220+
"DependsOn": "LambdaCreateCognitoExecutionRole",
179221
"Type": "AWS::Lambda::Function",
180222
"Properties": {
181223
"Handler": "index.handler",
182224
"Runtime": "nodejs",
183-
"Role": { "Fn::GetAtt" : ["LambdaCognitoExecutionRole", "Arn"] },
225+
"Role": { "Fn::GetAtt" : ["LambdaCreateCognitoExecutionRole", "Arn"] },
184226
"Code": {
185227
"ZipFile": {
186228
"Fn::Join": ["\n", [
@@ -253,12 +295,12 @@
253295
},
254296

255297
"UpdateCognitoIdentityPool": {
256-
"DependsOn": "LambdaCognitoExecutionRole",
298+
"DependsOn": "LambdaUpdateCognitoExecutionRole",
257299
"Type": "AWS::Lambda::Function",
258300
"Properties": {
259301
"Handler": "index.handler",
260302
"Runtime": "nodejs",
261-
"Role": { "Fn::GetAtt" : ["LambdaCognitoExecutionRole", "Arn"] },
303+
"Role": { "Fn::GetAtt" : ["LambdaUpdateCognitoExecutionRole", "Arn"] },
262304
"Code": {
263305
"ZipFile": {
264306
"Fn::Join": ["\n", [

0 commit comments

Comments
 (0)