# Referencing HttpApi base URL in serverless.yml

**URL:** https://forum.serverless.com/t/referencing-httpapi-base-url-in-serverless-yml/12683
**Category:** Serverless Framework
**Tags:** aws, api-gateway
**Created:** [September 27, 2020, 2:10pm UTC](https://forum.serverless.com/t/referencing-httpapi-base-url-in-serverless-yml/12683 "2020-09-27T14:10:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![muhwu](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@muhwu](https://forum.serverless.com/u/muhwu)
#### Post date: [September 27, 2020, 2:10pm UTC](https://forum.serverless.com/t/referencing-httpapi-base-url-in-serverless-yml/12683/1 "2020-09-27T14:10:03Z")

</div>

I was previously referencing a REST API URL through:

```
    !Join
      - ''
      - - 'https://'
        - !Ref ApiGatewayRestApi
        - '.execute-api.'
        - ${opt:region, self:provider.region}
        - '.amazonaws.com/'
        - ${opt:stage, self:provider.stage}

```

However, since my app is not rest, I have moved to using HttpApi events instead of REST events, i.e.

```
- httpApi:
      method: POST
      path: /register

```

How can I reference the path to this to pass it as an environment variable to my lambda?

---

<div class="post-metadata">

### Author: ![alexvdvalk](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/alexvdvalk/32/4449_2.png) [@alexvdvalk](https://forum.serverless.com/u/alexvdvalk)
#### Post date: [October 1, 2020, 1:50pm UTC](https://forum.serverless.com/t/referencing-httpapi-base-url-in-serverless-yml/12683/2 "2020-10-01T13:50:40Z")

</div>

Serverless Framwork creates an output called “HttpApiUrl” when deploying. I looked in the template update stack that is generated and lifted this CloudFormation code from there. I’m using the JSON format here so you may have to adjust if you’re using yaml.

```
    environment: {
  ImportedValue: {
    "Fn::Join": [
      "",
      [
        "https://",
        {
          Ref: "HttpApi",
        },
        ".execute-api.",
        {
          Ref: "AWS::Region",
        },
        ".",
        {
          Ref: "AWS::URLSuffix",
        },
      ],
    ],
  },
}

```

I hope this helps.

---

<div class="post-metadata">

### Author: ![muhwu](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@muhwu](https://forum.serverless.com/u/muhwu)
#### Post date: [October 1, 2020, 2:00pm UTC](https://forum.serverless.com/t/referencing-httpapi-base-url-in-serverless-yml/12683/3 "2020-10-01T14:00:23Z")

</div>

It does, thank you! Exactly what I was looking for. I haven’t worked with Serverless for long and even less with CloudFormation so this just saved me a ton of digging.

Thanks!
