Skip to content

Resolution error: No construct named was found, the ${construct:..} variable is invalid. unit serverless v4 #442

@piolet

Description

@piolet

Description

I am currently migrating a multi-service project from Serverless Framework v3 to Serverless Framework v4.

Before the migration, with Serverless v3, the same project and same Lift constructs were working correctly.
After upgrading to Serverless v4 and deploying through Serverless Compose, some services now fail during variable resolution with errors saying that local Lift constructs cannot be found, even though they are clearly declared in the same serverless.yml.

Questions

Has anyone already encountered this issue when migrating from Serverless v3 to v4, especially when using Lift + Compose?

At this stage, it looks like `${construct:...} resolution may behave differently under Serverless v4 / Compose compared to v3, even when the construct is locally declared in the same service.

How to Reproduce

I have a monorepo using serverless compose with multiple services.

Two examples:

1. backend service

In apis/back/serverless.yml I have:

provider:
  environment:
    DYNAMODB_CACHE_TABLE: ${construct:cacheTable.tableName}

constructs:
  cacheTable:
    type: database/dynamodb-single-table
    ...

1. s3-manager service

In apis/s3-manager/serverless.yml I have:

resources:
  Resources:
    S3ApiDomain:
      Type: AWS::Route53::RecordSet
      Properties:
        Name: ${construct:s3-api.cname}
        ...

constructs:
  s3-api:
    type: server-side-website
    ...

resources:
  Resources:
    S3DomainIpV4:
      Type: AWS::Route53::RecordSet
      Properties:
        ...
        Name: s3.${self:custom.domain}
        Type: A
        AliasTarget:
          ...
          DNSName: ${construct:s3-api.cname}

Both constructs are declared in the same service file where they are referenced.

Actual behavior

During serverless deploy with Compose on Serverless v4, I get errors like:

✖ s3-manager
  Resolution error: No construct named 's3-api' was found, the ${construct:s3-api.cname} variable is invalid.

✖ backend
  Resolution error: No construct named 'cacheTable' was found, the ${construct:cacheTable.tableName} variable is invalid.

Expected behavior

Since the constructs are declared in the same serverless.yml, I would expect ${construct:...} references to resolve correctly, as they did previously with Serverless v3.

Additional Information

This setup was working before on Serverless Framework v3
The issue appeared while migrating to Serverless Framework v4
The project is deployed via Serverless Compose
The problem affects at least:
${construct:cacheTable.tableName}
${construct:s3-api.cname}

Other services in the same compose deployment can still deploy successfully
Initially I also had a separate issue with a local plugin path (./vendor/bref/bref), but that has been fixed and is unrelated to this construct-resolution problem

Versions

Serverless Framework: 4.33.0
serverless-lift: 1.34.3
Node.js: 22

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions