# Error in referencing an httpApi lambda

**URL:** <https://forum.serverless.com/t/error-in-referencing-an-httpapi-lambda/20125>\
**Category:** Serverless Framework\
**Tags:** lambda\
**Created:** [May 5, 2024, 10:35pm UTC](https://forum.serverless.com/t/error-in-referencing-an-httpapi-lambda/20125 "2024-05-05T22:35:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zainzafar](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/zainzafar/32/1060_2.png) [@zainzafar](https://forum.serverless.com/u/zainzafar)\
**Post date:** [May 5, 2024, 10:35pm UTC](https://forum.serverless.com/t/error-in-referencing-an-httpapi-lambda/20125/1 "2024-05-05T22:35:04Z")

</div>

Hi,

I have the following test serverless.yml:

```auto
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:

```auto
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.
