k1LoW / serverless-s3-sync

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

bucketPrefix uploads one file too much (not in localDir) #86

Closed patrickbussmann closed 2 years ago

patrickbussmann commented 3 years ago

Very small serverless.yml:

service: example

provider:
    name: aws
    stage: ${opt:stage, 'dev'}
    region: eu-central-1
    runtime: provided.al2

custom:
    s3Sync:
        -   bucketNameKey: UpdateBucketName
            bucketPrefix: app/
            localDir: update
            params:
                -   "*.json":
                        CacheControl: 'no-cache'

plugins:
    - serverless-s3-sync

resources:
    Resources:
        UpdateBucket:
            Type: AWS::S3::Bucket
            Properties:
                AccessControl: PublicRead
        UpdateBucketPolicy:
            Type: AWS::S3::BucketPolicy
            Properties:
                Bucket: !Ref UpdateBucket
                PolicyDocument:
                    Statement:
                        -   Effect: Allow
                            Principal: '*'
                            Action: 's3:GetObject'
                            Resource: !Join [ '/', [ !GetAtt UpdateBucket.Arn, '*' ] ]

    Outputs:
        UpdateBucketName:
            Value: !Ref UpdateBucket

Deployment works successful.

S3 Sync: Syncing directories and S3 prefixes...
...........
S3 Sync: Synced.
S3 Sync: Syncing metadata...
.
S3 Sync: Synced metadata.
S3 Sync: Updating bucket tags...
.
S3 Sync: Updated bucket tags.
Serverless: Removing old service artifacts from S3...

And then I have one file too much in my bucket.

manifest.json
app/manifest.json
app/update.zip.001
app/update.zip.002
app/update.zip.003
app/update.zip.004
app/update.zip.005

Everything fine except the manifest.json which is in root directory. But I used the bucketPrefix so that this shouldn't happen.

The timestamp is like the others. When I remove the file manually and run sls deploy again the file is again there.

Maybe there is an logical issue with the bucketPrefix?