# Unable to get variables when files are in different folders

**URL:** <https://forum.serverless.com/t/unable-to-get-variables-when-files-are-in-different-folders/16390>\
**Category:** Serverless Framework\
**Tags:** variables\
**Created:** [December 11, 2021, 1:55pm UTC](https://forum.serverless.com/t/unable-to-get-variables-when-files-are-in-different-folders/16390 "2021-12-11T13:55:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonyeezs](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jonyeezs/32/5860_2.png) [@jonyeezs](https://forum.serverless.com/u/jonyeezs)\
**Post date:** [December 11, 2021, 1:55pm UTC](https://forum.serverless.com/t/unable-to-get-variables-when-files-are-in-different-folders/16390/1 "2021-12-11T13:55:42Z")

</div>

Need some help with my aws configuration.  
I have multiple services with its own `serverless.yml` but i do have another serverless.yml at root, which contains some services (for reasons) and a `resources.serverless.yml`

```auto
// Here's the folder struct
- services
   - A
     - serverless.yml
   - B
   - C
- serverless.yml (for B and C)
- resources.serverless.yml

```

```auto
// ./services/A/serverless.yml
projectDir: ../../

functions:
 A:
  events:
      - sqs:
          arn: !Ref EventSomething

resources:
  Resources: ${file(../../resources.serverless.yml):Resources}

```

```auto
// ./serverless.yml
functions:
   C:
    name: bee

resources:
  Resources: ${file(./resources.serverless.yml):Resources}

```

```auto
// ./resources.serverless.yml

Resources:
 EventSomething:
   Type: AWS::SQS::Queue
 EVENTC:
   Type: AWS::SNS::Topic
   Properties:
     TopicName: ${file(./serverless.yml):functions.C.name}-DL

```

When i try to build and deploy A, this is the error i get

> Cannot resolve serverless.yml: Variables resolution errored with:  
> - Cannot resolve variable at “resources.ResourcesEVENTC.Properties.TopicName”: Value not found at “file” source,

When i change the relative pathing in `resources.serverless.yml` to `../../serverless.yml`, it works!

Clearly the file import’s relative path is all out of whack. If i do keep it to that then i can’t deploy my `./serverless.yml` as that relative path of `../../` would be wrong!

How can i achieve my setup? Or should i be thinking about this a different way.  
Mainly i’m just trying to be DRY

---

<div class="post-metadata">

**Author:** ![medikoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/medikoo/32/4462_2.png) [@medikoo](https://forum.serverless.com/u/medikoo)\
**Post date:** [January 5, 2022, 9:43am UTC](https://forum.serverless.com/t/unable-to-get-variables-when-files-are-in-different-folders/16390/2 "2022-01-05T09:43:25Z")

</div>

@jonyeezs Unfortunately `file` variable paths in the Framework are always (even in imported files) resolved in relation to the service directory.

So in case of A, service directory is `./services/A` so `file(./serverless.yml)` (as listed in `./resources.serverless.yml`) will reach for `./services/A/serverless.yml` (and not `./serverless.yml` as you probably anticipate).

It’s a known issue (see [Variables: ${file..} source paths resolved always against service path · Issue #6039 · serverless/serverless · GitHub](https://github.com/serverless/serverless/issues/6039)), we plan to address it at some point, but currently, ETA is unknown (it’ll always help to +1 on that)

In your case, the best way to mitigate that, would be to place all service configuration at same level som for B at `./services/B` and for C at `./services/C`
