#13876·serverless

Support references on sandbox environment variables

Author: Hi-FiCreated Sep 15, 2026Updated Sep 15, 2026
Labelsbug

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Use case description

Currently I have environment variables defines like:

# provider.environment
    KNOWLEDGE_BASE_ID_POLICY: ${self:custom.knowledgeBaseIdPolicy.${self:provider.stage}, self:custom.knowledgeBaseIdPolicy.default}

For lambdas this creates Cloudformation like (with serverless package):

 # properties.environment.variables
            "KNOWLEDGE_BASE_ID_POLICY": {
              "Fn::GetAtt": [
                "BedrockKnowledgeBasePolicy",
                "KnowledgeBaseId"
              ]
            },

But same within sandbox (when explicitly mapping same environment variables to sandbox with environment: ${self:provider.environment}:

# properties.EnvironmentVariables
          {
            "Key": "KNOWLEDGE_BASE_ID_POLICY",
            "Value": "[object Object]"
          }

Proposed solution (optional)

Minimal would be that those references would go similarly to CloudFormation to Sandboxes than those go to Lambda Functions.

Other thing would be should those ${self:provider.environment} values come automatically also to sandboxes as those come to lambdas.