How to reference the current file dir


#1

Hey all.

I’ve got the following folder structure

root
|
|_configs
|    |_step-functions
|    |   |_my-step-function.yml
|    |_functions
|        |_external
|            |_external-functions.yml
|_services
    |_my-service
        |_serverless.yml
        |_config
            |_functions
                 |_my-function.yml

My serverless.yml file looks like this
functions:
my-function: {file(config/functions/my-function.yml)} step-functions: my-step-function: {file(…/…/configs/step-functions/my-step-function.yml):myStepFunction}

And my-step-function.yml looks like this
myStepFunction:
States:
State1:
Type: Task
Resource: {file(configs/functions/external/external-functions.yml):lambda.arn} Next: State2 State2: Type: Task Resource: {file(services/config/functions/my-function.yml):arn}
End: true

The problem is, when the step function is pulled into the serverless.yml file in the service directory, it seems to use that as the root for determining for where it needs to look for files. So, I need to alter the external resource to look 2 directories up for the proper lambda arn.
How can I get the current directory and act accordingly?

Or, should I rework the way I’ve structured this?

This step-function will be used across services, so it needs to be reusable and somewhere where other services can pull it in and make use of it easily.