title: CloudFormation - not able to create Lambda Function
body: <p>I am trying to create a Lambda Function and Lambda TriggeronSQS. Following is my cloud Formation template -</p>
  
  <h1>Template</h1>
  
  <pre><code>{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Resources": {
      "myfunction": {
          "Type": "AWS::Lambda::Function",
          "Properties": {
              "Runtime": "java8",
              "Role": "arn:aws:iam::219560220147:role/test@123",
              "Code": {
                  "S3Bucket": "lambdacode1234",
                  "S3Key": "code.jar"
              },
              "MemorySize": 256,
              "Handler": "com.test.MyHandler",
              "Timeout": 25
          },
          "Metadata": {
              "AWS::CloudFormation::Designer": {
                  "id": "63dae6c8-ebdb-459b-88db-02ad5dae294a"
              }
          }
      },
      "LESM34AJN": {
          "Type": "AWS::Lambda::EventSourceMapping",
          "Properties": {
              "EventSourceArn":"  arn:aws:sqs:ap-south-1:219560220147:testlambda",
              "FunctionName": {
          "Fn::GetAtt": [
              "myfunction",
              "Arn"
          ]
      },
              "BatchSize" : 1,
              "Enabled" : "TRUE"
          },
          "Metadata": {
              "AWS::CloudFormation::Designer": {
                  "id": "26a65289-5f1e-41db-b94d-812d2340c945"
              }
          }
      }
  },
  "Mappings": {
      "RegionCodeMapping": {
          "us-east-1": {
              "regionCode": "US"
          },
          "us-west-2": {
              "regionCode": "FE"
          },
          "eu-west-1": {
              "regionCode": "EU"
          }
      }
  },
  "Parameters": {
      "teamname": {
          "Description": "Enter Name TeamName",
          "Type": "String",
          "AllowedPattern": "^[a-z0-9-]*$"
      },
      "env": {
          "Description": "Enter Envirment type e.g. dev,test,prod",
          "Type": "String",
          "AllowedValues": [
              "devo",
              "test",
              "prod"
          ]
      },
      "sqsARNtoTriggerLambda": {
          "Type": "String"
      },
      "codeFile": {
          "Type": "String"
      }
  },
  "Outputs": {
      "LambdaFunctionARN": {
          "Description": "ARN of Lambda Function",
          "Value": {
              "Fn::GetAtt": [
                  "myfunction",
                  "Arn"
              ]
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <h1>ERROR</h1>
  
  <p>I tried creating stack via AWS Console, but receiving below error for SQS policy creation </p>
  
  <blockquote>
    <p>1 validation error detected: Value ' arn:aws:sqs:ap-south-1:219560220147:testlambda' at 'eventSourceArn' failed to satisfy constraint: Member must satisfy regular expression pattern: arn:(aws[a-zA-Z0-9-]<em>):([a-zA-Z0-9-])+:([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.</em>) (Service: AWSLambda; Status Code: 400; Error Code: ValidationException; Request ID: 9a86cb1e-49e4-490d-9e48-fd93aa8d81dd)</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/3RkHk.png" rel="nofollow noreferrer">CloudFormation Console Error</a></p>
  
  <p>I have referred the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html" rel="nofollow noreferrer">documentation </a> but can't figure out what the problem is? Any ideas what is wrong here?</p>