# Split serverless.yml apigw big events nodes

**URL:** <https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, api-gateway\
**Created:** [February 15, 2022, 9:07am UTC](https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721 "2022-02-15T09:07:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![m0rph3u5-zip](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/m0rph3u5-zip/32/6595_2.png) [@m0rph3u5-zip](https://forum.serverless.com/u/m0rph3u5-zip)\
**Post date:** [February 15, 2022, 9:07am UTC](https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721/1 "2022-02-15T09:07:06Z")

</div>

Hello there,

I was wondering if it was possible to split a serverless.yml file into multiple files.  
In particular, I have a fairly large lamba function api gateway. My “events” node is growing very hard and becoming difficult to manage.

I CANT divide the function, for me it is !important that it is only one api service.  
Its possible to divide the “events” node of the serverless yml into several files, perhaps for each resource of my api service for example:

users-events.serverless.yml;  
posts-events.serverless.yml;  
and so on?

I attach my serverless.yml

 ![sample](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/f/f26bc9f5a7f4c2a25ad1e0175627514f8aff9ba0.png)

I hope it is doable.  
thank you all.

---

<div class="post-metadata">

**Author:** ![corin](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@corin](https://forum.serverless.com/u/corin)\
**Post date:** [February 18, 2022, 2:50pm UTC](https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721/2 "2022-02-18T14:50:18Z")

</div>

This is not something I’ve tried but from the documentation ([Serverless Variables](https://www.serverless.com/framework/docs/providers/aws/guide/variables#reference-properties-in-other-files)) it looks like you could do it. Maybe something like:

```auto
functions:
  graphql:
    ...
    events:
      ${file(./users-events.serverless.yml):events}
      ${file(./posts-events.serverless.yml):events}

```

Maybe. Try experimenting with that or something like it.

---

<div class="post-metadata">

**Author:** ![m0rph3u5-zip](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/m0rph3u5-zip/32/6595_2.png) [@m0rph3u5-zip](https://forum.serverless.com/u/m0rph3u5-zip)\
**Post date:** [February 18, 2022, 4:31pm UTC](https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721/3 "2022-02-18T16:31:11Z")

</div>

Dude, thanks for answering me.

It’s something I’ve tried with no success. Unfortunately I do not understand, and the doc does not clarify, how to possibly structure the file in the variable.

My test is:

 ![tried](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/3/387fcca95beab764a8b63eb6b3b923142b8c8f26.png)

---

<div class="post-metadata">

**Author:** ![corin](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@corin](https://forum.serverless.com/u/corin)\
**Post date:** [February 18, 2022, 4:50pm UTC](https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721/4 "2022-02-18T16:50:06Z")

</div>

I think the way the roles file is structured is okay. I believe the problem is how you included it in the parent file. Instead of

```auto
events:
  - roles: ${file(./src/serverless/roles.serverless.yml).roles}

```

try

```auto
events:
  ${file(./src/serverless/roles.serverless.yml).roles}

```

---

<div class="post-metadata">

**Author:** ![m0rph3u5-zip](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/m0rph3u5-zip/32/6595_2.png) [@m0rph3u5-zip](https://forum.serverless.com/u/m0rph3u5-zip)\
**Post date:** [February 21, 2022, 10:23am UTC](https://forum.serverless.com/t/split-serverless-yml-apigw-big-events-nodes/16721/5 "2022-02-21T10:23:36Z")

</div>

Unfortunately none of the attempts work!

Test 1:

 ![Error-1](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/4/4afb40d998f2f722babd67fb8ade42defa9262b8.png)  
Test 2:  
 ![Error-2](https://canada1.discourse-cdn.com/flex036/uploads/serverless/original/2X/d/d9ab264f37770a94174173afc4a0a577e394b251.png)
