콘텐츠로 이동

Prune Plugin

Prune Plugin: AWS Lambda Storage Limit Error

섹션 제목: “Prune Plugin: AWS Lambda Storage Limit Error”
author: Onejay
createdAt: 2024-06-26
updatedAt: 2024-08-14

Terminal window
Code storage limit exceeded. (Service: Lambda, Status Code: 400, ...)
  • sls 로 deploy 할 때만 사용하므로 dev dependency 로 충분하다

    Terminal window
    npm install --save-dev serverless-prune-plugin
  • YAML 설정을 통해 Deploy 를 할 때마다 동일한 처리를 할 수 있다.

    service: example-service
    plugins:
    - serverless-prune-plugin
    custom:
    prune:
    automatic: true
    number: 3
    # includeLayers: true
    • number

      • 3인 경우 방금 deploy 한 버전 포함 최신 3개만 남기고 모두 지운다.
    • includeLayers

      • AWS Lambda Layer 의 이전 버전도 삭제할 것인가?
  • Deploy

    • 플러그인을 설정한 뒤 sls 로 deploy 하면 아래와 같은 메시지가 나온다.

      Terminal window
      Pruning of functions complete
  • sls command 를 이용한다면 수동으로도 삭제 할 수 있다.

    Terminal window
    $ sls prune -n 3 -c serverless.yaml