Coder Social home page Coder Social logo

grunt-cloudfront's Introduction

grunt-cloudfront

Grunt task for invalidating cache on Amazon AWS CloudFront with the official AWS SDK for node.js.

Get Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-cloudfront --save-dev

Then add this line to your project's Gruntfile.js gruntfile:

grunt.loadNpmTasks('grunt-cloudfront');

Usage

// Project configuration.
grunt.initConfig({
  cloudfront: {
    options: {
      region:'us-east-1', // your AWS region
      distributionId:"YOUR_DISTRIBUTION_ID", // DistributionID where files are stored
      awsProfile: 'default',
      listInvalidations:true, // if you want to see the status of invalidations
      listDistributions:false, // if you want to see your distributions list in the console
      version:"1.0" // if you want to invalidate a specific version (file-1.0.js)
    },
    dev: {
      options: {
        distributionId: '** DEV KEY **'
      },
      CallerReference: Date.now().toString(),
      Paths: {
        Quantity: 1,
        Items: [ '/index.html' ]
      }
    },
    live: {
      options: {
        distributionId: '** LIVE KEY **'
      },
      CallerReference: Date.now().toString(),
      Paths: {
        Quantity: 1,
        Items: [ '/index.html' ]
      }
    }
  }
});

AWS Credentials

If an awsProfile parameter is supplied, the aws-sdk will read credentials from that profile and use them for your invalidation job. If no awsProfile is supplied, credentials will be loaded from the following environment variables if available:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY

You can also store them in a git ignored credential file and pass them as options to the grunt job:

{
  "accessKeyId": "ACCESS_KEY",
  "secretAccessKey": "SECRET_ACCESS_KEY"
}

Then in the job options:

grunt.initConfig({
  cloudfront: {
    options: {
      region:'us-east-1', // your AWS region
      distributionId:"YOUR_DISTRIBUTION_ID", // DistributionID where files are stored
      credentials:grunt.file.readJSON('path/to/aws/credentials.json'), // !!Load them from a gitignored file
      listInvalidations:true,
      listDistributions:false,
      version:"1.0"
    }
  }

Release History

  • January 21, 2014 - 0.2.1 Allow loading of AWS credentials from env
  • March 10, 2014 - 0.2.0 Add multi task option configuration (thanks @steve8708)
  • February 27, 2014 - 0.1.1 Fix dependencies
  • May 14, 2013 - 0.1.0 First release

License

Florent Lamoureux
Licensed under the MIT license.
Copyright (c) 2013 - http://www.payrollhero.com

grunt-cloudfront's People

Contributors

flrent avatar jpellizzari avatar mboudreau avatar santialbo avatar steve8708 avatar tommoor avatar v6 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

grunt-cloudfront's Issues

Build invalidation batch from paths in configuration

Instead of having to include a valid invalidation batch, why not build the invalidation batch from a much simpler configuration?

Please see sspinc/grunt-cloudfront@30db42bd0290040392ea24ddd16da8adc82172d4 in our fork. This is the only difference and we would love to contribute this back in a backwards-compatible manner by checking the configuration whether it already includes Paths and CallerReference or it expects grunt-cloudfront to assemble it).

It would make it much easier to invalidate paths, especially if they are determined dynamically.

Fatal error: Cannot read property 'length' of null

I'm getting this error:

Fatal error: Cannot read property 'length' of null

Actually it says:

Invalidation succeeded. Please wait a few minutes.OK
{ 
Location: 'https://cloudfront.amazonaws.com/',
Id: ''
/** normal account data */
}
Fatal error: Cannot read property 'length' of null

I've checked from aws console, it is actually creating invalidation rule, but is not waiting for it to be completed.

Working on directories

Did you know how can i invalidate each file on a virtual directory?

Example:

/builds/*.

Is there a way to ignore on dev?

Currently my package.json contains a postscript that runs grunt build once I run npm install.

I would like the option to ignore to run cloudfront if process.env.NODE_ENV === 'development'.

Is there a way to perform this task?

Add a changelog generation

@payrollhero/devs,

We need a changelog generation so every update on S3 and CloudFront is logged. Already saw some cool grunt tasks, but none of them seems to integrate easily.
If anyone has an idea, please comment here.

devDependencies not install when running npm install

Step 1. Create a standard project
Step 2. Run npm install grunt-cloudfront --save-dev
Step 3. Look in the node_modules/grunt-cloudfront folder

There is no node_modules within the grunt-cloudfront dir. I'm not quite sure what's causing this bug? I've been getting round it by manually going to the node_modules/grunt-cloudfront directory and running npm install there.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.