带有SAM CLI的Lambda层

时间:2019-12-26 19:40:07

标签: python-3.x aws-lambda-layers

我成功地创建了一个无服务器的lambda层,但是现在我必须对SAM CLI做同样的事情,但是我做不到。

在没有服务器的情况下,我仅使用两个文件:

  • serverless.yml
  • awswrangler-layer-0.0.23-py3.7.zip

serverless.yml内容如下:

service: MyService

provider:
  name: aws

layers:
  awswrangler:
    package:
      artifact: awswrangler-layer-0.0.23-py3.7.zip

如何使用SAM CLI执行相同操作?请举例说明template.yaml

2 个答案:

答案 0 :(得分:0)

我必须解压缩,这是解决方案:

  AwswranglerLayer :
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: !Join ['-', [!Ref Project, !Ref Environment, 'AwswranglerLayer']]
      ContentUri: ../layers/awswrangler/
      Description: "ETL and wrangling utility belt to handle data on AWS. Pandas, PySpark"
      CompatibleRuntimes:
        - python3.7
        - python3.8
      RetentionPolicy: Retain

答案 1 :(得分:0)

AwswranglerLayer: 类型:AWS :: Serverless :: LayerVersion 特性: LayerName:!Sub'$ {EnvironmentKey} -AwswranglerLayer' 兼容的运行时间: -nodejs12.x ContentUri:AwswranglerLayerPath /