Lambda props does not allow you to bring your own Role
See original GitHub issueI don’t know how to attach my own role to a Lambda function – the props won’t accept one, and the .role
attribute is read-only. I usually write a dedicated role to associate with any Lambda function, or reference one that has been created independently. ‘@aws-cdk/lambda’ Lambda
seems to be hard-wired to provide its own service role?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
interface FunctionProps · AWS CDK
Whether to allow the Lambda to send all network traffic. allowPublicSubnet? boolean, Lambda Functions in a public subnet can NOT access the internet....
Read more >Specifying a custom role for lambda with the AWS CDK
A Lambda already comes with an execution role, and it already has the basic execution permissions. If you want to add additional permissions ......
Read more >How to add permissions to Lambda Functions in AWS CDK
In order to add permissions to a Lambda Function, we have to attach a policy to the function's role. The code for this...
Read more >How to Create AWS CDK Lambda Functions? 4 Easy Steps
You can design your code into AWS CDK Lambda functions that process ... you can also provide your own IAM role, though permission...
Read more >Hello Lambda | AWS CDK Workshop
You 've hit ${event.path}\n` }; }; This is a simple Lambda function which ... Save your code, and let's take a quick look...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For others that arrive here looking for how to create the IRole object needed, use the from_role_arn method of the Role class in aws_cdk.aws_iam.
Example Python code:
will create an IRole object that can be passed as a parameter to Lambda Function.
I didn’t managed to add role during lambda creation, but next code gives to lambda access to external role, created in another CDK: