sam deploy I couldn't import from Lambda Function just by doing sam build before printing, so I investigated the cause.
Lambda Layer Template
Resources:
SystemSharedLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: src/layers/system_shared
CompatibleRuntimes:
- python3.8
Metadata:
BuildMethod: python3.8
** Lambda Layer Src structure **
src
└── layers
└── system_shared
├── python
│ └── hogehoge.py
└── requirements.txt
** Caller **
import hogehoge.py
** If you didn't sam build **
/opt
└── python/
└── hogehoge.py
** When sam build **
/opt
└── python/
└── python/← Extra pass is given
└── hogehoge.py
Since the specifications are inconsistent, give up and switch the hierarchy specification on the template side
Resources:
SystemSharedLayer:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri: src/layers/system_shared/python
CompatibleRuntimes:
- python3.8
Metadata:
BuildMethod: python3.8
Recommended Posts