• Stars
    star
    174
  • Rank 219,104 (Top 5 %)
  • Language
    JavaScript
  • Created over 11 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Grunt interface into the Amazon Node.JS SDK

grunt-aws

A Grunt interface into the Amazon Web Services Node.JS SDK aws-sdk

NPM version

Getting Started

This plugin requires Grunt 0.4.x

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install --save-dev grunt-aws

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-aws');

Supported Services

This plugin aims to provide a task for each service on AWS. Currently however, it only supports:


The "s3" task

Features

  • Fast
  • Simple
  • Auto Gzip
  • Smart Local Caching

Usage

To upload all files inside build/ into my-awesome-bucket:

  grunt.initConfig({
    aws: grunt.file.readJSON("credentials.json"),
    s3: {
      options: {
        accessKeyId: "<%= aws.accessKeyId %>",
        secretAccessKey: "<%= aws.secretAccessKey %>",
        bucket: "my-awesome-bucket"
      },
      build: {
        cwd: "build/",
        src: "**"
      }
    }
  });

See the complete example here

Options

accessKeyId required (String)

Amazon access key id

secretAccessKey required (String)

Amazon secret access key

bucket required (String)

Bucket name

sessionToken (String)

Amazon session token, required if you're using temporary access keys

region (String)

Default US Standard

For all possible values, see Location constraints.

sslEnabled (Boolean)

Default true

SSL is enabled or not

maxRetries (Number)

Default 3

Number of retries for a request

access (String)

Default "public-read"

File permissions, must be one of:

  • "private"
  • "public-read"
  • "public-read-write"
  • "authenticated-read"
  • "bucket-owner-read"
  • "bucket-owner-full-control"

gzip (Boolean)

Default true

Gzips the file before uploading and sets the appropriate headers

Note: The default is true because this task assumes you're uploading content to be consumed by browsers developed after 1999. On the terminal, you can retrieve a file using curl --compressed <url>.

dryRun (Boolean)

Default false

Performs a preview run displaying what would be modified

concurrency (Number)

Default 20

Number of S3 operations that may be performed concurrently

overwrite (Boolean)

Default true

Upload files, whether or not they already exist (set to false if you never update existing files).

CopyFile (String)

Default None

Path to copy filewithin S3. ex. my-bucket2/output/d.txt

CopyFrom (String)

Default None

Path to copy all files within S3. ex. my-bucket2/output/

cache (Boolean)

Default true

Skip uploading files which have already been uploaded (same ETag). Each target has it's own options cache, so if you change the options object, files will be forced to reupload.

cacheTTL (Number)

Default 60*60*1000 (1hr)

Number of milliseconds to wait before retrieving the object list from S3. If you only modify this bucket from grunt-aws on one machine then it can be Infinity if you like. To disable cache, set it to 0.

headers (Object)

Set HTTP headers, please see the putObject docs

The following are allowed:

  • ContentLength
  • ContentType (will override mime type lookups)
  • ContentDisposition
  • ContentEncoding
  • CacheControl (accepts a string or converts numbers into header as max-age=<num>, public)
  • Expires (converts dates to strings with toUTCString())
  • GrantFullControl
  • GrantRead
  • GrantReadACP
  • GrantWriteACP
  • ServerSideEncryption ("AES256")
  • StorageClass ("STANDARD" or "REDUCED_REDUNDANCY")
  • WebsiteRedirectLocation

The properties not listed are still available as:

  • ACL - access option above
  • Body - the file to be uploaded
  • Key - the calculated file path
  • Bucket - bucket option above
  • Metadata - meta option below

meta (Object)

Set custom HTTP headers

All custom headers will be prefixed with x-amz-meta-. For example {Foo:"42"} becomes x-amz-meta-foo:42.

charset (String)

Add a charset to every one of your Content-Type. For example: utf-8. If this is not set, then all text files will get charset of UTF-8 by default.

mime (Object)

Define your own mime types

This object will be passed into mime.define()

mimeDefault (String)

Default "application/octet-stream"

The default mime type for when mime.lookup() fails

createBucket (Boolean)

Default false

Create the bucket if it does not exist. Use the bucket option to name the bucket. Use the access and region as parameters when creating the bucket.

enableWeb (object)

Default false

Configure static web hosting for the bucket. Set to true to enable the default hosting with the IndexDocument set to index.html. Otherwise, set the value to be an object that matches the parameters required for WebsiteConfiguration in putBucketWebsite docs.

Caching

First run will deploy like:

Running "s3:uat" (s3) task
Retrieving list of existing objects...
>> Put 'public/vendor/jquery.rest.js'
>> Put 'index.html'
>> Put 'scripts/app.js'
>> Put 'styles/app.css'
>> Put 'public/img/loader.gif'
>> Put 'public/vendor/verify.notify.js'
>> Put 6 files

Subsequent runs should look like:

Running "s3:uat" (s3) task
>> No change 'index.html'
>> No change 'public/vendor/jquery.rest.js'
>> No change 'styles/app.css'
>> No change 'scripts/app.js'
>> No change 'public/img/loader.gif'
>> No change 'public/vendor/verify.notify.js'
>> Put 0 files

Explained Examples

s3: {
  //provide your options...

  options: {
    accessKeyId: "<%= aws.accessKeyId %>",
    secretAccessKey: "<%= aws.secretAccessKey %>",
    bucket: "my-bucket"
  },

  //then create some targets...

  //upload all files within build/ to root
  build: {
    cwd: "build/",
    src: "**"
  },

  //upload all files within build/ to output/
  move: {
    cwd: "build/",
    src: "**",
    dest: "output/"
  },

  //upload and rename an individual file
  specificFile: {
    src: "build/a.txt",
    dest: "output/b.txt"
  },

  //upload and rename many individual files
  specificFiles: {
    files: [{
      src: "build/a.txt",
      dest: "output/b.txt"
    },{
      src: "build/c.txt",
      dest: "output/d.txt"
    }]
  },

  //upload and rename many individual files (shorter syntax)
  specificFilesShort: {
    "output/b.txt": "build/a.txt"
    "output/d.txt": "build/c.txt"
  },

  //upload the img/ folder and all it's files
  images: {
    src: "img/**"
  },

  //upload the docs/ folder and it's pdf and txt files
  documents: {
    src: "docs/**/*.{pdf,txt}"
  },

  //upload the secrets/ folder and all its files to a different bucket
  secrets: {
    //override options
    options: {
    	bucket: "my-secret-bucket"
    }
    src: "secrets/**"
  },

  //upload the public/ folder with a custom Cache-control header
  longTym: {
    options: {
      headers: {
        CacheControl: 'max-age=900, public, must-revalidate'
      }
    }
    src: "public/**"
  },

  //upload the public/ folder with a 2 year cache time
  longTym: {
    options: {
      headers: {
        CacheControl: 630720000 //max-age=630720000, public
      }
    }
    src: "public/**"
  },

  //upload the public/ folder with a specific expiry date
  beryLongTym: {
    options: {
      headers: {
        Expires: new Date('2050') //Sat, 01 Jan 2050 00:00:00 GMT
      }
    }
    src: "public/**"
  },

  //Copy file directly from s3 bucket to a different bucket
  copyFile: {
    src: "build/c.txt",
    dest: "output/d.txt",
    options: {
      copyFile: "my-bucket2/output/d.txt"
    }
  },

  //Copy all files in directory
  copyFiles: {
    src: "public/**",
    options: {
      copyFrom: 'my-bucket2/public'
    }
  }

}

References

Todo

  • Download operation
  • Delete unmatched files

The "route53" task

Features

  • Create DNS records using simple configuration
  • Smart Local Caching

Usage

To create two new records - the first resolving to an IP address and the second resolving to the domain name a bucket:

  grunt.initConfig({
    aws: grunt.file.readJSON("credentials.json"),
    route53: {
      options: {
        accessKeyId: "<%= aws.accessKeyId %>",
        secretAccessKey: "<%= aws.secretAccessKey %>",
        zones: {
		      'mydomain.org': [{
             name: 'record1.mydomain.org',
             type: 'A',
             value: ['1.1.1.1']
          },{
            name: 'record2.mydomain.org',
            type: 'CNAME',
            value: ['record2.mydomain.org.s3-website-ap-southeast-2.amazonaws.com']
          }]
        }
      }
    }
  });

Options

accessKeyId required (String)

Amazon access key id

secretAccessKey required (String)

Amazon secret access key

assumeRole (Boolean)

Use AWS IAM Role instead of credentials

zones required (Object)

An object containing names of zones and a list of DNS records to be created for this zone in Route 53.

Each record requires name, type and value to be set. The name property is the new domain to be created. The type is the DNS type e.g. CNAME, ANAME, etc.. The value is a list of domain names or IP addresses that the DNS entry will resolve to.

It is also possible to specify any of the additional options described in the ResourceRecordSet section of the changeResourceRecordSets method. For example, AliasTarget could be used to set up an alias record.

TTL (Number)

Default 300

Default TTL of any new Route 53 records.

dryRun (Boolean)

Default false

Performs a preview run displaying what would be modified

concurrency (Number)

Default 20

Number of Route53 operations that may be performed concurrently

cache (Boolean)

Default true

Cache data returned from Route 53. Once records

References

Todo

  • Better support for alias records
  • Create zones?

The "cloudfront" task

Features

  • Invalidate a list of files, up to the maximum allowed by CloudFront, like /index.html and /pages/whatever.html
  • Update CustomErrorResponses
  • Update OriginPath on the first origin in the distribution, other origins will stay the same
  • Update DefaultRootObject

Usage

A sample configuration is below. Each property must follow the requirements from the CloudFront updateDistribution Docs.

  grunt.initConfig({
    aws: grunt.file.readJSON("credentials.json"),
    cloudfront: {
      options: {
        accessKeyId: "<%= aws.accessKeyId %>",
        secretAccessKey: "<%= aws.secretAccessKey %>",
        distributionId: '...',
      },
      html: {
        options: {
          invalidations: [
            '/index.html',
            '/pages/whatever.html'
          ],
          customErrorResponses: [ {
            ErrorCode: 0,
            ErrorCachingMinTTL: 0,
            ResponseCode: 'STRING_VALUE',
            ResponsePagePath: 'STRING_VALUE'
          } ],
          originPath: 'STRING_VALUE',
          defaultRootObject: 'STRING_VALUE'
        }
      }
    }
  });

Options

accessKeyId required (String)

Amazon access key id

secretAccessKey required (String)

Amazon secret access key

distributionId required (String)

The CloudFront Distribution ID to be acted on

invalidations optional (Array)

An array of strings that are each a root relative path to a file to be invalidated

customErrorResponses optional (Array)

An array of objects with the properties shown above

originPath optional (String)

A string to set the origin path for the first origin in the distribution

defaultRootObject optional (String)

A string to set the default root object for the distribution

The "sns" task

Features

  • Publish to a SNS topic

Usage

To public a message

  grunt.initConfig({
    aws: grunt.file.readJSON("credentials.json"),
    cloudfront: {
      options: {
        accessKeyId: "<%= aws.accessKeyId %>",
        secretAccessKey: "<%= aws.secretAccessKey %>",
        region: '<%= aws.region %>',
        target: 'AWS:ARN:XXXX:XXXX:XXXX',
        message: 'You got it',
        subject: 'A Notification'
      }
    }
  });

Options

accessKeyId required (String)

Amazon access key id

secretAccessKey required (String)

Amazon secret access key

region required (String)

The region that the Topic is hosted under

target required (String)

The AWS ARN for the topic

message required (String)

The message content for the notification

subject required (String)

The subject to use for the notification

References

Todo

  • Add other SNS functionality

MIT License

Copyright Β© 2013 Jaime Pillora <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

chisel

A fast TCP/UDP tunnel over HTTP
Go
12,490
star
2

cloud-torrent

☁️ Cloud Torrent: a self-hosted remote torrent client
Go
5,744
star
3

xdomain

A pure JavaScript CORS alternative
JavaScript
3,072
star
4

overseer

Monitorable, gracefully restarting, self-upgrading binaries in Go (golang)
Go
2,276
star
5

notifyjs

Notify.js - A simple, versatile notification library
1,903
star
6

xhook

Easily intercept and modify XHR request and response
HTML
983
star
7

webproc

Wrap any program in a simple web-based user-interface
Go
725
star
8

docker-dnsmasq

dnsmasq in a docker container, configurable via a simple web UI
Dockerfile
723
star
9

go-tcp-proxy

A small TCP proxy written in Go
Go
694
star
10

backoff

Simple backoff algorithm in Go (golang)
Go
627
star
11

jquery.rest

A jQuery plugin for easy consumption of RESTful APIs
CoffeeScript
614
star
12

ipfilter

A package for IP Filtering in Go (golang)
Go
386
star
13

node-edit-google-spreadsheet

A simple API for editing Google Spreadsheets
JavaScript
304
star
14

base64-encoder

Base64 Encoder
HTML
260
star
15

installer

One-liner for installing binaries from Github releases
Go
200
star
16

node-torrent-cloud

Torrent Cloud – A self-hosted Bittorrent client in the Cloud
JavaScript
183
star
17

velox

Real-time Go struct to JS object synchronisation over SSE and WebSockets
Go
180
star
18

opts

A Go (golang) package for building frictionless command-line interfaces
Go
162
star
19

verifyjs

Verify.js - A powerful, customizable asynchronous validation library
JavaScript
159
star
20

ssh-tron

Multiplayer Tron over SSH, written in Go
Go
143
star
21

go-ogle-analytics

Monitor your Go (golang) servers with Google Analytics
HTML
133
star
22

cloud-gox

A Go (golang) Cross-Compiler in the cloud
Go
132
star
23

media-sort

Automatically organise your movies and tv series
Go
118
star
24

go-tld

TLD Parser in Go
Go
114
star
25

node-load-tester

Simple load testing with Node.js
JavaScript
88
star
26

sshd-lite

A feature-light sshd(8) for Windows, Mac, and Linux written in Go
Go
85
star
27

csv-to-influxdb

Import CSV files into InfluxDB
Go
81
star
28

node-logbook

A simple, unobtrusive logger for Node
JavaScript
61
star
29

spy

Spy - Watches for file changes, restarts stuff
Go
61
star
30

go-and-ssh

Go and the Secure Shell protocol
Go
58
star
31

node-glob-all

Provide multiple patterns to node-glob
JavaScript
57
star
32

serve

Your personal HTTP file server in Go
Go
53
star
33

go-sandbox

An alternate frontend to the Go Playground
JavaScript
52
star
34

scraper

A dual interface Go module for building simple web scrapers
Go
50
star
35

node-google-sheets

Google Sheets v4 API using Node.js
JavaScript
44
star
36

dedup

A cross platform command-line tool to deduplicate files, fast
Go
42
star
37

archive

Archiver is a high-level API over Go's archive/tar,zip
Go
33
star
38

icmpscan

ICMP scan all hosts across a given subnet in Go (golang)
Go
29
star
39

hashedpassword

A small Go (Golang) package for hashed passwords
Go
26
star
40

gswg-examples

Getting Started with Grunt - Code Examples
JavaScript
25
star
41

webfont-downloader

A small web service which converts webfonts into zip archives
Go
24
star
42

aoc-in-go

A template repository for rapidly writing Advent of Code solutions in Go
Go
21
star
43

conncrypt

Symmetrically encrypt your Go net.Conns
Go
19
star
44

s3hook

Transparent Client-side S3 Request Signing
JavaScript
19
star
45

grunt-source

Reuse a Grunt environment across multiple projects
JavaScript
18
star
46

docker-cloud-torrent-openvpn

cloud-torrent and OpenVPN in a docker container
Shell
17
star
47

longestcommon

Longest common prefix/suffix across of list of strings in Go (Golang)
Go
16
star
48

mega-stream

Stream media content from Mega
JavaScript
14
star
49

node-gitlab-deploy

Deploy a Node server via a Gitlab Webhook
JavaScript
13
star
50

go-template

An automatic cross-compiling Go (golang) repository template using goreleaser and Github actions
Shell
13
star
51

ansi

Easy to use ANSI control codes
Go
12
star
52

subfwd

URL shortening via sub-domains, written in Go
HTML
12
star
53

js-play

A JavaScript playground/sandbox for learning, testing and prototyping
CSS
12
star
54

upnpctl

A small UPnP client
Go
11
star
55

go-echo-server

View your requests in JSON format
Go
10
star
56

node-echo-server

Responds with the JSONified Request
JavaScript
10
star
57

ddns-daemon

A Simple Dynamic DNS Daemon using Node.js and Route53
JavaScript
10
star
58

whos-home

ARP scan your subnet and POST findings
Go
10
star
59

uploader

A small server to receive files over HTTP
JavaScript
9
star
60

dynflare

DynamicDNS using Cloudflare
Go
9
star
61

pnode

peer-to-peer dnode over anything!
JavaScript
9
star
62

go433

Send and receive 433 MHz using a RaspberryPi and Go
Go
9
star
63

sockfwd

Forward a unix socket to a tcp socket
Go
9
star
64

vip

An IPv4 addressing Go (golang) module, based on uint32 instead of []byte
Go
8
star
65

ipflare

Find your public IP address according to Cloudflare
Go
8
star
66

node-ssh-http-agent

An HTTP agent for tunnelling through SSH connections
JavaScript
7
star
67

eventsource

An eventsource event encoder in Go (golang)
Go
7
star
68

sizestr

Pretty print byte counts in Go
Go
7
star
69

docker-caddy

Caddy in a docker container, configurable via a simple web UI
Dockerfile
7
star
70

sleep-on-lan

Send your computer to sleep via HTTP
JavaScript
7
star
71

requestlog

Simple request logging in Go (golang)
Go
6
star
72

pnode-store

A synchronized data store between connected Node.js applications
JavaScript
6
star
73

castlebot

🏰 A bot for your castle
Go
5
star
74

docker-vpn

Dockerized SoftEther VPN with a Web GUI
Shell
5
star
75

node-imdb-sort

Sort files based on IMDB data
CoffeeScript
5
star
76

jquery.prompt

Styled text prompts any element
CoffeeScript
5
star
77

gswg-io

Getting Started with Grunt - Homepage
HTML
5
star
78

compilejs

A mini Grunt.js for the browser
CoffeeScript
5
star
79

go-realtime

Keep your Go structs in sync with your JS objects
JavaScript
4
star
80

md-tmpl

Simple markdown templating using shell commands
Go
4
star
81

cookieauth

Cookie-based Basic-Authentication HTTP middleware for Go (golang)
Go
4
star
82

maplock

A map of locks in Go
Go
4
star
83

opts-examples

A Go (golang) package for building frictionless command-line interfaces
Go
4
star
84

go-mime

Extends pkg/mime with embedded mime types
Go
4
star
85

tranquil

Generate powerful RESTful JSON APIs
CoffeeScript
3
star
86

ipmath

IP Address Math in Go (golang)
Go
3
star
87

xtls

TLS utils
Go
3
star
88

puzzler

A programming puzzle framework in Go
Go
3
star
89

goff

Concatenate audio files, built with Go and FFmpeg
Go
3
star
90

prettyprinter

Simple Pretty Printer using Google's Prettify
HTML
3
star
91

github-badge-maker

Github Badge Maker
JavaScript
3
star
92

opts-talk

A talk on opts, for the Sydney Go Meetup
Go
3
star
93

grunt-source-web

A Grunt Source project to build optimized static websites
CoffeeScript
3
star
94

playground

Next version of https://js.jpillora.com
2
star
95

node-king

The king of your nodes - A powerful command and control center for your server infrastructure
JavaScript
2
star
96

bookshelf

Your personal bookshelf
HTML
2
star
97

debator-lander

Interactive and transparent debates online
2
star
98

webscan

Scans the entire Web for particular server types and devices
2
star
99

xmlfmt

A pure Go streaming XML formatter
Go
2
star
100

vigilant

Simple CLI tool for running multiple CLI tools in the same process
JavaScript
2
star