# @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.

Latest version **4.2.0** (published 2019-10-29) · Apache license · 0 weekly downloads

## Install

```sh
npm install @serverless/aws-s3
pnpm add @serverless/aws-s3
yarn add @serverless/aws-s3
bun add @serverless/aws-s3
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2019-10-29 |
| First published | 2019-03-20 |
| Weekly downloads | 0 |
| License | Apache |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Serverless, Inc. |
| Maintainers | aj.stuyvenberg, dschep, eahefnawy, pmuens |

## Links

- npm: https://www.npmjs.com/package/@serverless/aws-s3
- npm.io page: https://npm.io/package/@serverless/aws-s3

## Dependencies (8)

- [ramda](https://npm.io/package/ramda.md) ^0.26.1
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.488.0
- [archiver](https://npm.io/package/archiver.md) ^3.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.0
- [klaw-sync](https://npm.io/package/klaw-sync.md) ^6.0.0
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.22
- [@serverless/core](https://npm.io/package/@serverless/core.md) ^1.0.0
- [s3-stream-upload](https://npm.io/package/s3-stream-upload.md) ^2.0.2

## Recent versions

- 4.2.0 (latest) — 2019-10-29
- 4.1.0 — 2019-10-14
- 4.0.0 — 2019-09-26
- 3.1.0 — 2019-09-05
- 3.0.1 — 2019-08-28
- 3.0.0 — 2019-08-20
- 2.0.12 — 2019-08-02
- 2.0.11 — 2019-08-02
- 2.0.10 — 2019-08-02
- 2.0.9 — 2019-08-01
- 2.0.8 — 2019-07-31
- 2.0.7 — 2019-07-25
- 2.0.6 — 2019-07-25
- 2.0.5 — 2019-07-24
- 2.0.4 — 2019-07-24
- … 23 more at https://npm.io/package/@serverless/aws-s3/versions

## README

# 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.

&nbsp;

1. [Install](#1-install)
2. [Create](#2-create)
3. [Configure](#3-configure)
4. [Deploy](#4-deploy)
5. [Upload](#5-upload)

&nbsp;


### 1. Install

```console
$ npm install -g serverless
```

### 2. Create

Just create a `serverless.yml` file

```console
$ touch serverless.yml
$ touch .env      # your AWS api keys
```

```
# .env
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
```


### 3. Configure

```yml
# 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

```console
$ 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.
 
```js

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](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) headers can also be set:

```js

// 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](https://github.com/serverless-components/website/).

&nbsp;

### New to Components?

Checkout the [Serverless Components](https://github.com/serverless/components) repo for more information.

---
_Source: https://npm.io/package/@serverless/aws-s3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
