# Compose Error: Cannot resolve '${param:xxx}' variable at 'provider.environment.yyyy'

**URL:** <https://forum.serverless.com/t/compose-error-cannot-resolve-param-xxx-variable-at-provider-environment-yyyy/20541>\
**Category:** Serverless Framework\
**Tags:** variables\
**Created:** [September 14, 2024, 7:34pm UTC](https://forum.serverless.com/t/compose-error-cannot-resolve-param-xxx-variable-at-provider-environment-yyyy/20541 "2024-09-14T19:34:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juergen.gethealthy](https://avatars.discourse-cdn.com/v4/letter/j/df705f/32.png) [@juergen.gethealthy](https://forum.serverless.com/u/juergen.gethealthy)\
**Post date:** [September 14, 2024, 7:34pm UTC](https://forum.serverless.com/t/compose-error-cannot-resolve-param-xxx-variable-at-provider-environment-yyyy/20541/1 "2024-09-14T19:34:50Z")

</div>

Hello all -

I’m new to serverless. I hope someone can look at this and tell me what’s wrong… been reading and beating my head against the wall all day long. This has got to be something super simple…

Here’s my project definition:

```auto
serviceA/
  serverless.yml
infra/
  serverless.yml
serverless-compose.yml

```

**serverless-compose.yml**

```auto
# serverless-compose.yml
services:
  serviceA:
    path: serviceA
    params:
      region: ${infra.region}
      integrationsTable: ${infra.integrationsTable}
    dependsOn:
      - infra

  infra:
    path: infra

```

**infra/serverless.yml**

```auto
service: infra

provider:
  name: aws
  runtime: nodejs20.x
  region: us-east-1
  stage: ${opt:stage, 'dev'}
  profile: serverlessUser
custom:
 tables:
    integrationsTable: "${sls:stage}-integrations"

resources:
  Resources:
    IntegrationsTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:custom.tables.integrationsTable}
        ...
        ...
  Outputs:
    region: ${self:provider.region}
    integrationsTable: ${self:custom.tables.integrationsTable}

```

**serviceA/serverless.yml**

```auto
service: serviceA

provider:
  name: aws
  runtime: nodejs20.x
  region: ${param:region}
  profile: serverlessUser
  stage: ${opt:stage, 'dev'}
  environment:
    integrationsTable: ${param:integrationsTable}

functions:
  register:
  ...
  ...

```

From the project directory, when I run **sls package** , dev, info or deploy I get the following:

```auto
Packaging "infra" for stage "dev" (us-east-1)

✔ Service packaged (1s)

✔ Ran package on Service: infra

✖ Serverless Compose failed to run "package" on "serviceA"

✖ Could not resolve the parameter 'region'. Please ensure that it is correctly defined in the Compose configuration and that all dependent services are deployed. If the services are deployed, verify that their state is up to date by running 'deploy' or 'info' command on the Compose file.

```

When I cd into **serviceA** directory and try to build from there, it’s the same thing.

It is my understanding per documentation here [https://www.serverless.com/framework/docs/guides/compose](https://www.serverless.com/framework/docs/guides/compose) that **Outputs** defined in a service are mapped to other services by way of **params**

Also if I remove the region property in `serviceA/serverless.yml`, it stops with the same error at `integrationsTable`

Clearly, my params aren’t communicated to the service. Why?

What am I doing wrong here?

---

<div class="post-metadata">

**Author:** ![TomC](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tomc/32/4002_2.png) [@TomC](https://forum.serverless.com/u/TomC)\
**Post date:** [September 17, 2024, 2:36pm UTC](https://forum.serverless.com/t/compose-error-cannot-resolve-param-xxx-variable-at-provider-environment-yyyy/20541/2 "2024-09-17T14:36:14Z")

</div>

I’d define region (and any other shared params) in the top level file, and refer to it from the two children. Does that work any better ?

---

<div class="post-metadata">

**Author:** ![juergen.gethealthy](https://avatars.discourse-cdn.com/v4/letter/j/df705f/32.png) [@juergen.gethealthy](https://forum.serverless.com/u/juergen.gethealthy)\
**Post date:** [September 17, 2024, 10:00pm UTC](https://forum.serverless.com/t/compose-error-cannot-resolve-param-xxx-variable-at-provider-environment-yyyy/20541/3 "2024-09-17T22:00:55Z")

</div>

Thanks for your reply.

I’m not sure I follow. By `toplevel` are you referring to `serverless-compose.yml`? Or some sort of shared yml file to be included/referenced in the microservices?

What I’ve figured out this:

You can’t cd into a mircroservice directory and run `serverless deploy` for example. The params are referenced from a neighboring service and `serverless` does not move up the directory chain to discover where to find the parameters. This make sense. Though it would be cool if that could be done somehow.

What does work howver is to run `serverless deploy --service projectA` from the parent directory. This circumvents the error because serverless considers `serverless-compose.yml` first in this case and resolves everything.

---

<div class="post-metadata">

**Author:** ![TomC](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tomc/32/4002_2.png) [@TomC](https://forum.serverless.com/u/TomC)\
**Post date:** [September 19, 2024, 7:15am UTC](https://forum.serverless.com/t/compose-error-cannot-resolve-param-xxx-variable-at-provider-environment-yyyy/20541/4 "2024-09-19T07:15:17Z")

</div>

My understanding is you have

```auto
toplevel.yml
childA/some.yml
childB/thing.yml

```

All your variables should be defined in `toplevel.yml`
