The role defined for the function cannot be assumed by Lambda

0 votes

I'm getting the error "The role defined for the function cannot be assumed by Lambda" when I'm trying to create a lambda function with create-function command.

aws lambda create-function
--region us-west-2
--function-name HelloPython
--zip-file fileb://hello_python.zip
--role arn:aws:iam::my-acc-account-id:role/default
--handler hello_python.my_handler
--runtime python2.7
--timeout 15
--memory-size 512

Sep 24, 2018 in AWS by bug_seeker
• 15,350 points
895 views

1 answer to this question.

0 votes

I got the error "The role defined for the function cannot be assumed by Lambda" because i had not updated the roles "Trust Relationship" config file. I didn't encounter the timeout issues as in the linked answer in the comments.

The comments in the above answers pointed out that you need to add the following.

  1. Go to 'IAM > Roles > YourRoleName'
    • (Note: if your role isn't listed, then you need to create it.)
  2. Select the 'Trust Relationships' tab
  3. Select 'Edit Trust Relationship'

Mine ended up like the below.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      <your other rules>
    },
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
answered Sep 24, 2018 by Priyaj
• 56,520 points

Related Questions In AWS

0 votes
1 answer

Error when tried to invoke lambda function by AWS CLI

It looks like you need to provide ...READ MORE

answered Sep 10, 2018 in AWS by Archana
• 4,090 points
447 views
0 votes
1 answer

How do I add python libraries to an AWS lambda function for Alexa?

As it is described in the Amazon ...READ MORE

answered Oct 23, 2018 in AWS by Archana
• 4,090 points
322 views
0 votes
1 answer

What is the job role for a AWS pre-sales architect?

The AWS Pre Sales Architect will be ...READ MORE

answered Nov 30, 2018 in AWS by Aniket
357 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer