k1LoW / serverless-s3-sync

A plugin to sync local directories and S3 prefixes for Serverless Framework :zap:
182 stars 68 forks source link

Validation errors when specifying cache-control #38

Closed luludan closed 4 years ago

luludan commented 4 years ago

I'm trying to specify cache-control headers with this syntax:

  s3Sync:
    - bucketName: ${self:custom.s3Bucket} 
      localDir: .dir/sub_dir
      bucketPrefix: _dir/sub_dir 
      params:
        - '**/*.js':
          CacheControl: 'public, max-age=31536000, immutable'
        - '**/*.css':
          CacheControl: 'public, max-age=31536000, immutable'
        - '**/*.woff':
          CacheControl: 'public, max-age=31536000, immutable'

But am getting this error when trying to run sls deploy

S3 Sync: Syncing directories and S3 prefixes...
.... 
  Multiple Validation Errors -----------------------------

  MultipleValidationErrors: There were 35 validation errors:
  * UnexpectedParameter: Unexpected key '0' found in params
  * UnexpectedParameter: Unexpected key '1' found in params
  * UnexpectedParameter: Unexpected key '2' found in params
  * UnexpectedParameter: Unexpected key '3' found in params
  * UnexpectedParameter: Unexpected key '4' found in params
.
.
.

Not sure quite what I'm doing wrong here

nibynool commented 4 years ago

@luludan, sorry for the late reply. I think you need to indent the CacheControl lines by an additional 2 spaces.

If this doesn't work can you please advise what version you're using? If you're no longer using the plugin or have resolved the issue please close the issue.

Thanks.

danielbayerlein commented 4 years ago

Adding two additional spaces works for me!

s3Sync:
  - bucketName: ${self:custom.s3Bucket} 
    localDir: .dir/sub_dir
    bucketPrefix: _dir/sub_dir 
    params:
      - '**/*.js':
          CacheControl: 'public, max-age=31536000, immutable'
      - '**/*.css':
          CacheControl: 'public, max-age=31536000, immutable'
      - '**/*.woff':
         CacheControl: 'public, max-age=31536000, immutable'
coyoteecd commented 4 years ago

@k1LoW Can confirm that indenting CacheControl as shown above works correctly (and this is how it's documented in the readme). I think you can close this.

k1LoW commented 4 years ago

@coyoteecd Thank you !!