Socket
Socket
Sign inDemoInstall

arc-buckets-plugin

Package Overview
Dependencies
266
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    arc-buckets-plugin

Make buckets and use them for good stuff!


Version published
Maintainers
1
Install size
75.4 MB
Created

Readme

Source

Arc Buckets Plugin

Architect serverless framework plugin that creates s3 buckets

ALPHA WARNING: this plugin is pretty early in development and everything here is subject to change

This plugin makes it super simple to use aws s3 in an architect project to store files

@buckets
pictures
const profilePic = await buckets.pictures.get('ankcorn/profile.jpg')

Installation

  1. Install this plugin npm i arc-buckets-plugin

  2. Add the following line to the @plugins pragma in your Architect project manifest (usually app.arc):

     @plugins
     arc-buckets-plugin
    

Usage

Each bucket you define under the @buckets section will be created in AWS.

@buckets
pictures
kittens

To do something to bucket use the generated client found at src/shared/buckets.

For example:

Add a file to your bucket

const buckets = require('@architect/shared/buckets');

async function handler(req) {
	await buckets.kittens.put('list-of-kitten-names.txt', req.body)
}

Get a file from your bucket

const buckets = require('@architect/shared/buckets');

async function handler(req) {
	return {
		statusCode: 200,
		body: await buckets.kittens.get('list-of-kitten-names.txt');
	}
}

Triggers

Invoking lambdas for ObjectCreated or ObjectRemoved events is supported. To create a lambda that will be invoked for one of these events add triggers to the bucket.

@buckets
dogs
	triggers create

cats
	triggers remove

Opt out of the client and use the aws-sdk

The generated client found at @architect/shared/buckets will cover common usecases but sometimes you need to do something only supported by the aws-sdk. The generated client will still help you set this up correctly and make sure the sandbox works.

const buckets = require('@architect/shared/buckets');
const S3 = require('aws-sdk/clients/s3');

const s3 = new S3(buckets.awsConfig);

s3.getObject({ Bucket: buckets.dogs.bucketName, Key: '...' })

TODO

  • Add list and delete methods to the client
  • Add support for s3 buckets that already exist
  • Add suport for bucket visibilty options

FAQs

Last updated on 28 Mar 2021

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