title: AccessDeniedException when deploying the lambda function
body: <p>I am trying to create the lambda function in aws through the AWS command.When I am executing the command, getting the below error. But the role which I've mentioned in the AWS command has enough permission in order to deploy the lambda function.I'm not sure what went wrong even though role has permission. </p>
  
  <p><strong>Command:</strong></p>
  
  <pre><code>aws lambda create-function --function-name ukmon-appd-disabled- 
  health-rules --runtime python3.7 --zip-file 
  fileb://bin/disabled_health_rules.zip --handler index.handler --timeout 10 - 
  -memory-size 1024 --role arn:aws:iam::99999999999:role/crossaccount
  </code></pre>
  
  <p><strong>Policies:</strong></p>
  
  <pre><code>"AllowLambdaFunctionStack": {
        "Type": "AWS::IAM::ManagedPolicy",
        "Properties": {
          "Description": "Policy for allowing jenkins cross account service role to create, update, delete lambda functions.",
          "Path": "/",
          "PolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
              {
                "Action": [
                  "lambda:InvokeFunction",
                  "lambda:CreateFunction",
                  "lambda:DeleteFunction",
                  "lambda:GetFunction",
                  "lambda:ListFunctions",
                  "lambda:UpdateFunctionCode",
                  "lambda:GetFunctionConfiguration",
                  "lambda:UpdateFunctionConfiguration",
                  "lambda:AddPermission",
                  "lambda:RemovePermission",
                  "lambda:CreateAlias",
                  "lambda:DeleteAlias",
                  "lambda:GetAlias",
                  "lambda:ListAliases",
                  "lambda:UpdateAlias",
                  "lambda:GetPolicy",
                  "lambda:InvokeAsync",
                  "lambda:ListVersionsByFunction",
                  "lambda:PublishVersion",
                  "lambda:CreateEventSourceMapping",
                  "lambda:GetEventSourceMapping",
                  "lambda:ListEventSourceMappings",
                  "lambda:DeleteEventSourceMapping",
                  "lambda:UpdateEventSourceMapping",
                  "lambda:TagResource",
                  "lambda:ListTags",
                  "lambda:UntagResource"
                ],
                "Effect": "Allow",
                "Resource": "arn:aws:lambda:eu-west-1:999999999999:function:crossaccount-*",
                "Sid": "AllowLambdaFuctionsStacks"
              }
            ]
          },
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>An error occurred (AccessDeniedException) when calling the
    CreateFunction operation: User:
    arn:aws:sts::999999999999:assumed-role/crossaccount/i-0d2dd689c2784f174
    is not authorized to perform: lambda:CreateFunction on resource:
    arn:aws:lambda:eu-west-1:999999999999:function:ukmon-appd-disabled-health-rules</p>
  </blockquote>
  
  <p>Thanks in advance.</p>