BPm
BPm

Reputation: 2994

CloudFormation: The role defined for the function cannot be assumed by Lambda

I've been searching for this error and nothing really answers how I can fix it with my CloudFormation template. From the events log, I can see that the role was created before the Lambda functions.

Could you please help?

Upvotes: 1

Views: 4956

Answers (1)

Andreas
Andreas

Reputation: 984

You are probably missing an AssumeRolePolicyDocument allowing Lambda (lambda.amazonaws.com) to assume your IAM role.

Example:

...
"LambdaRole": {
    "Type": "AWS::IAM::Role",
    "Properties": {
        "AssumeRolePolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [{
                "Effect": "Allow",
                "Principal": {"Service" : "lambda.amazonaws.com"},
                "Action": ["sts:AssumeRole"]
            }]
        },
        "Path": "/",
        "Policies": [...]
    }
}
...

Upvotes: 2

Related Questions