aghadiry / serverless-cloudfront-invalidate

Serverless plugin that allows you to invalidate Cloudfront Cache
MIT License
29 stars 22 forks source link

TypeError: elements.map is not a function on running serverless cloudfrontInvalidate #44

Open mazensharkawy opened 1 year ago

mazensharkawy commented 1 year ago

On running serverless cloudfrontInvalidate I get the following error

Environment: linux, node 14.21.3, framework 3.35.2, plugin 7.0.2, SDK 4.4.0
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues
Error:
TypeError: elements.map is not a function
    at CloudfrontInvalidate.invalidateElements (/opt/atlassian/pipelines/agent/build/node_modules/serverless-cloudfront-invalidate/index.js:100:43)
    at CloudfrontInvalidate.invalidate (/opt/atlassian/pipelines/agent/build/node_modules/serverless-cloudfront-invalidate/index.js:161:17)
    at PluginManager.runHooks (/usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js:530:15)
    at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js:564:20)
    at async PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/plugin-manager.js:604:7)
    at async Serverless.run (/usr/local/lib/node_modules/serverless/lib/serverless.js:179:5)
    at async /usr/local/lib/node_modules/serverless/scripts/serverless.js:819:9

This is my serverless.yml file

service: Lebara-Frontend

provider:
  name: aws
  runtime: nodejs18.x
  stage: ${opt:stage, 'dev'}
  region: ${env:AWS_DEFAULT_REGION, '*****'}
  bucketName: ${env:AWS_BUCKET_NAME, '******'} 

plugins:
  - serverless-finch
  - serverless-cloudfront-invalidate

custom:
  client:
    bucketName: ${self:provider.bucketName}
    distributionFolder: build
    indexDocument: index.html
    errorDocument: index.html
    objectHeaders:
      'static/':
        - name: Cache-Control
          value: 'max-age=31536000'
      '*.png':
        - name: Cache-Control
          value: 'max-age=31536000'
  cloudfrontInvalidate:
    distributionId: ${env:DISTRIBUTION_ID}
    items: # one or more paths required 
      - "/*"