Template Error: Instance of Fn: :Getatt References Undefined Resource Eventhandlerlambdafunction
Can Anyone Help Me Find What's Wrong? I'm Importing This Cloudformation Resources in My Serverless Yml. This Is My Function Config: Resources: eventHandler...
Can anyone help me find what's wrong?
I'm importing this cloudformation resources in my serverless yml. This is my function config:
Resources:
eventHandler:
Type: AWS::Serverless::Function
Properties:
CodeUri: eventLambda/
Handler: dist/app.eventHandler
Runtime: nodejs12.x
FunctionName: eventHandler
This where I'm referencing it:
eventSourceRule:
Type: 'AWS::Events::Rule'
Properties:
Name: eventSourceRule
EventBusName: omnibus-${self:custom.stage}
EventPattern: |
{
"source": ["op.api"]
}
RetryPolicy:
MaximumRetryAttempts: 5
MaximumEventAgeInSeconds: 900
DeadLetterConfig:
Type: SQS
QueueLogicalId: EBRuleDLQ
Targets:
- Arn:
Fn::GetAtt:
- 'EventHandlerLambdaFunction'
- 'Arn'
Id: 'eventSourceRule'
Notice that I've already tried eventHandler and EventHandler and none of these worked.
That's the error I'm receiving:
The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource EventHandlerLambdaFunction
1 Answer
I think you have to add the logical name of resource.
Replace EventHandlerLambdaFunction to actual resource name eventHandler.
You are not using the logical name of your Lambda resource you have defined.
You can try using the simple YAML syntax:
Targets:
- Arn: !GetAtt eventHandler.Arn
Reference: Fn::GetAtt AWS Documentation