4.2.0 • Published 5 years ago

@serverless/aws-s3 v4.2.0

Weekly downloads
24,782
License
Apache
Repository
-
Last release
5 years ago

aws-s3

Instantly deploy and manage your S3 buckets with Serverless Components. Supports acceleration as well as file & directory uploads.

 

  1. Install
  2. Create
  3. Configure
  4. Deploy
  5. Upload

 

1. Install

$ npm install -g serverless

2. Create

Just create a serverless.yml file

$ touch serverless.yml
$ touch .env      # your AWS api keys
# .env
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX

3. Configure

# serverless.yml

myBucket:
  component: "@serverless/aws-s3"
  inputs:
    accelerated: false # default is true. Enables upload acceleartion for the bucket
    region: us-east-1
    cors:
      CORSRules:
      - AllowedHeaders:
        - "*"
        AllowedMethods:
        - PUT
        - POST
        - DELETE
        AllowedOrigins:
        - http://www.example.com
        MaxAgeSeconds: 3000

4. Deploy

$ serverless

5. Upload

If you're using this component programmatically within another component, you could also easily upload files and/or directories to your bucket.

const bucket = await this.load('@serverless/aws-s3')

// deploy
await bucket({
  accelerated: true
})

// upload directory
await bucket.upload({ dir: './my-files' })

// upload file
await bucket.upload({ file: './my-file.txt' })

Cache-control headers can also be set:

// upload directory, setting cache-control headers
await bucket.upload({ dir: './my-files', cacheControl: 'max-age=86400' })

// upload file, setting cache-control header
await bucket.upload({ file: './my-file.txt', cacheControl: 'max-age=86400' })

For a full example on how this component could be used, take a look at how the website component is using it.

 

New to Components?

Checkout the Serverless Components repo for more information.

4.2.0

5 years ago

4.1.0

5 years ago

4.0.0

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.12

5 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago