Socket
Socket
Sign inDemoInstall

@serverless/aws-s3

Package Overview
Dependencies
87
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @serverless/aws-s3

Instantly deploy and manage your S3 buckets with [Serverless Components](https://github.com/serverless/components). Supports acceleration as well as file & directory uploads.


Version published
Weekly downloads
86K
increased by8.33%
Maintainers
4
Install size
62.2 MB
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 29 Oct 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc