Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to authorize lambda to perform ses:SendEmail with CDK?

I'm getting runtime exception:

AccessDenied: User arn:aws:sts::431535252:assumed-role/...some-lambda' is not authorized to perform 'ses:SendEmail' on resource `arn:aws:ses:us-east-1:52452465462:identity/[email protected]

Looking at the docs here, I wasn't able to figure out how to grant that permission.

like image 621
Daniel Birowsky Popeski Avatar asked Nov 19 '20 12:11

Daniel Birowsky Popeski


1 Answers

Currently, need to manually add a policy to the execution role for the lambda:

theLambda.addToRolePolicy(new iam.PolicyStatement({
  actions: ['ses:SendEmail', 'SES:SendRawEmail'],
  resources: ['*'],
  effect: iam.Effect.ALLOW,
}));
like image 75
Daniel Birowsky Popeski Avatar answered Nov 01 '22 13:11

Daniel Birowsky Popeski