Template error with AWS::Lambda::EventSourceMapping


#1

Hi, hope you may be able to help or point me to the documentation/example of this scenario. My goal use Type: AWS::Lambda::EventSourceMapping and reference the arn with Fn::GetAtt instead of the putting the Arn itself. This is so i can deploy without knowing the arn ahead of time and to different environments. But I am getting template error error when I try to deploy. Below is the configurations in the yml file, thank you very much in advance. Kind of crossed-eyed now, hope it’s something simple to fix :slight_smile:

Serverless version 1.5.1
Serverless Error ---------------------------------------

 Template error: if specifying one argument to Fn::GetAtt,
 that argument must be a non-empty string in format <LogicalId>.<Attribute>

 provider:
iamRoleStatements:
- Effect: Allow
  Action:
    - dynamodb:DescribeTable
    - dynamodb:Query
    - dynamodb:Scan
    - dynamodb:GetItem
    - dynamodb:PutItem
    - dynamodb:UpdateItem
    - dynamodb:DeleteItem
    - dynamodb:DescribeStream
    - dynamodb:GetRecords
    - dynamodb:GetShardIterator
    - dynamodb:ListStreams
  Resource: "arn:aws:dynamodb:us-east-1:*:*"

/* lambda event */
updateView:
name: updateView
environment:
      STAGE: ${self:custom.myStage}
      USER_POOL_ID: ${env:USER_POOL_ID}
      USER_POOL_CLIENT_ID: ${env:USER_POOL_CLIENT_ID}
handler: playlist/handler.updateView
events:
      - http:
          path: mypath
          method: post
          cors: true
resources:
Resources:
myViewTable:  <-- <LogicalID>
  Type: 'AWS::DynamoDB::Table'
  DeletionPolicy: Retain
  Properties:
    AttributeDefinitions:
      - AttributeName: id
        AttributeType: S
    KeySchema:
      - AttributeName: id
        KeyType: HASH
    ProvisionedThroughput:
      ReadCapacityUnits: 1
      WriteCapacityUnits: 1
    TableName: ${self:custom.myStage}-mydbViewTable
    StreamSpecification:
      StreamViewType: NEW_AND_OLD_IMAGES
StreamFunctionEventSourceMappingDynamodbMyTable:
  Type: AWS::Lambda::EventSourceMapping
  DependsOn:
    -IamRoleLambdaExecution
    -updateView
  Properties:
    BatchSize: 10
  EventSourceArn:
  Fn::GetAtt:
    -myViewTable
    -StreamArn
  FunctionName:
  Fn::GetAtt:
    -updateView
    -Arn
  StartingPosition: TRIM_HORIZON
  Enabled: True

#2

Were you able to figure this out? I have the same problem.


#3

Yeah i did. The issue is what i used in the LogicalID . In my original post above, I indicated the logicalID I used, and then it started working! I was referencing the DB table name previously.