You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS SAM公共层无法找到模块的问题求助

AWS SAM公共层无法找到模块的问题求助

大家好,我最近在搞AWS SAM项目的时候碰到个头疼的问题,折腾半天没搞定,想请各位帮忙分析下。

先给大家看下我的目录结构:

.
├── common/
│   ├── __init__.py
│   └── common.py
├── customer/
│   └── app.py
└── template.yaml

我的SAM模板内容是这样的:

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'

Resources:
  CommonLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: common-layer
      Description: Common code for multiple Lambda functions
      ContentUri: common/
      CompatibleRuntimes:
        - python3.11

  CustomerFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: app.lambda_handler
      Runtime: python3.11
      CodeUri: customer/
      MemorySize: 128
      Timeout: 30
      Environment:
        Variables:
          LOG_LEVEL: INFO
      Layers:
        - !Ref CommonLayer
      Events:
        CustomerApi:
          Type: Api
          Properties:
            Path: /customer/{customer_id}
            Method: get

.....

Outputs:
  CustomerApiEndpoint:
    Description: &q...

现在的问题是,我部署完这个应用后,调用CustomerFunction的时候,总是报错说找不到common模块。我明明已经把CommonLayer关联到这个Lambda函数上了,反复检查模板里的Layers配置也没看出问题,可就是不行。有没有大佬能帮我找找问题出在哪呀?

备注:内容来源于stack exchange,提问作者user4447899

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 09:53:03