Hi,
I have the following test serverless.yml:
service: test1
frameworkVersion: '3'
provider:
name: aws
runtime: nodejs18.x
iam:
role:
statements:
- Effect: "Allow"
Action:
- "lambda:InvokeFunction"
Resource:
- Fn::GetAtt: [ api, Arn ]
functions:
api:
handler: index.handler
events:
- httpApi:
path: /
method: get
api2:
handler: index.handler2
events:
- httpApi:
path: /api2
method: get
Deploying this gives the following error:
serverless deploy --stage dev --aws-profile default
Deploying test1 to stage dev (us-east-1)
✖ Stack test1-dev failed to deploy (68s)
Environment: darwin, node 20.12.2, framework 3.38.0, plugin 7.2.3, SDK 4.5.1
Credentials: Local, "default" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
The CloudFormation template is invalid: Template error: instance of Fn::GetAtt references undefined resource api
api
lambda function needs to invoke the second api2
lambda function and therefore needs InvokeFunction permission.