title: AWS CLI: The role defined for the function cannot be assumed by Lambda
body: <p>AWS CLI version:</p>
  
  <pre><code>aws --version
  aws-cli/1.11.21 Python/2.7.12 Darwin/15.3.0 botocore/1.4.78
  </code></pre>
  
  <p>Trying to create a Lambda function and getting the error:</p>
  
  <pre><code>An error occurred (InvalidParameterValueException) when calling the CreateFunction operation: The role defined for the function cannot be assumed by Lambda.
  </code></pre>
  
  <p>Role was created as:</p>
  
  <pre><code>aws iam create-role --role-name microrole --assume-role-policy-document file://./trust.json
  </code></pre>
  
  <p><code>trust.json</code> is:</p>
  
  <pre><code>{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Principal": {
          "Service": "lambda.amazonaws.com"
        },
        "Action": "sts:AssumeRole"
      }
    ]
  }
  </code></pre>
  
  <p>Policy was attached as:</p>
  
  <pre><code>aws iam put-role-policy --policy-document file://./policy.json --role-name microrole --policy-name micropolicy
  </code></pre>
  
  <p><code>policy.json</code> is:</p>
  
  <pre><code>{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "logs:CreateLogGroup",
          "logs:CreateLogStream",
          "logs:PutLogEvents"
        ],
        "Resource": "arn:aws:logs:*:*:*"
      },
      {
        "Effect": "Allow",
        "Action": [
          "apigateway:*"
        ],
        "Resource": "arn:aws:apigateway:*::/*"
      },
      {
        "Effect": "Allow",
        "Action": [
          "execute-api:Invoke"
        ],
        "Resource": "arn:aws:execute-api:*:*:*"
      }
    ]
  }
  </code></pre>
  
  <p>Waited for multiple minutes as mentioned at <a href="https://stackoverflow.com/questions/37503075/invalidparametervalueexception-the-role-defined-for-the-function-cannot-be-assu">[1]</a> and <a href="https://stackoverflow.com/questions/36419442/the-role-defined-for-the-function-cannot-be-assumed-by-lambda">[2]</a> but still the error is not going away. The policy and trust attached to the role is similar to the default role created when Lambda Function is created using Console.</p>
  
  <p>Complete steps are listed at <a href="https://github.com/arun-gupta/serverless/tree/master/aws/microservice" rel="nofollow noreferrer">https://github.com/arun-gupta/serverless/tree/master/aws/microservice</a>.</p>
  
  <p>What's missing?</p>