Skip to content

Commit

Permalink
Grant DescribeUserPoolClient to the backend Lambda
Browse files Browse the repository at this point in the history
gh-274

Taken from the workaround in the issue description here:
aws/aws-cdk#7112.

My error noted here:
aws/aws-cdk#7112 (comment)
  • Loading branch information
douglasnaphas committed Feb 19, 2021
1 parent 108b3ab commit 65028c7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/madliberation-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as cognito from "@aws-cdk/aws-cognito";
import { UserPool } from "@aws-cdk/aws-cognito";
const stackname = require("@cdk-turnkey/stackname");
const crypto = require("crypto");
import { Effect, PolicyStatement } from "@aws-cdk/aws-iam";

export class MadliberationStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
Expand Down Expand Up @@ -137,6 +138,16 @@ export class MadliberationStack extends cdk.Stack {
timeout: cdk.Duration.seconds(20),
});

fn.addToRolePolicy(
new PolicyStatement({
effect: Effect.ALLOW,
actions: ["cognito-idp:DescribeUserPoolClient"],
resources: [
`arn:aws:cognito-idp:${userPool.stack.region}:${userPool.stack.account}:userpool/${userPool.userPoolId}`,
],
})
);

clientSecretBucket.grantRead(fn);

const lambdaApi = new apigw.LambdaRestApi(this, "Endpoint", {
Expand Down

0 comments on commit 65028c7

Please sign in to comment.