Git Product home page Git Product logo

gulp-cloudfront's People

Contributors

niftylettuce avatar nitaigao avatar remie avatar steadicat 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gulp-cloudfront's Issues

Change default pattern to use "-" hyphen

I figured I'd file an issue to see if it was OK with you before I submitted a PR.

-options.patternIndex = options.patternIndex || /^\/index\.[a-f0-9]{8}\.html(\.gz)*$/gi;
+options.patternIndex = options.patternIndex || /^\/index\-[a-f0-9]{8}\.html(\.gz)*$/gi;

I suggest this considering that gulp-rev and gulp-rev-all by default out of the box use this approach.

IMPORTANT! Outdated AWS SDK exposes issue with sSLSupportMethod being set to 'VIP'

Starting mid-October 2018 there is a confirmed issue with the AWS API when used in combination with older SDK versions (before at least 2015-09-17). This issue causes the CloudFront distribution that is updated using the UpdateDistribution to switch the supported SSL method from 'SNI only' to 'Virtual IP', regardless of the request parameters.

As shown in this CloudTrail Event:

{
    "eventVersion": "1.03",
    ...
    "eventSource": "cloudfront.amazonaws.com",
    "eventName": "UpdateDistribution",
    ...
    "userAgent": "aws-sdk-nodejs/2.0.31 linux/v6.8.1",
    "requestParameters": {
        "distributionConfig": {
            ...
            "viewerCertificate": {
                "sSLSupportMethod": "sni-only",
                "minimumProtocolVersion": "TLSv1"
            },
            ...
        }
    },
    "responseElements": {
        ...
        "distribution": {
            "distributionConfig": {
                ...
                "viewerCertificate": {
                    "sSLSupportMethod": "vip",
                    "minimumProtocolVersion": "TLSv1"
                },
                ...
            }
        }
    },
    ...
    "eventType": "AwsApiCall",
    "apiVersion": "2014_10_21",
    ...
}

the distribution request does have the correct value of the sSLSupportMethod, but the response from the API says it was changed to VIP. This will incur additional costs up to $600,-- USD per distribution per month.

The only way to avoid this issue is to update to the latest version of the SDK. Amazon Web Services is aware of the issue and has created an internal request to stop support for older SDK, which will eventually break this package.

Does this work with multiple index files?

Thanks for gulp-cloudfront, definitely solves a problem I had in a unique way. Does it support multiple index file in multiple directories? I have an index in root and an index in /app but I am getting this output.

....
[10:01:21] gulp-cloudfront: DefaultRootObject updated to [index.d474d950.html].
[10:01:21] gulp-cloudfront: Identified index [ /app/index.6a5485a0.html ]
[10:01:23] gulp-cloudfront: DefaultRootObject updated to [app/index.6a5485a0.html].
[10:01:23] Finished 'deploy' after 6.93 s

Which obviously doesn't work for root since the default root object is different signature for both. I believe the problem is that the 2nd index is not identified until after first DefaultRootObject is updated.

Thanks in advance.

Index.html reference not getting updated

My index file did get it's name updated: index.2e6ac32e.html

But the references inside are incorrect.

I see that the references in my css files did get updated correctly.

I see that the references in my js files got updated correctly

I see that the files that are in the revall ignore rule don't get the links/resources updated, I don't want the name changed but I want the references ok :).

Missing required key \'OriginAccessIdentity\'

Whenever I try to run gulp-cloudfront I receive the following error

  plugin: 'gulp-cloudfront',
  showStack: false,
  name: 'MissingRequiredParameter',
  message: 'Missing required key \'OriginAccessIdentity\' in params.DistributionConfig.Origins.Items[0].S3OriginConfig',
  stack: 'Error: Missing required key \'OriginAccessIdentity\' in params.DistributionConfig.Origins.Items[0].S3OriginConfig\n    at fail (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:99:26)\n    at validateStructure (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:18:14)\n    at validateMember (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:45:21)\n    at validateStructure (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:32:14)\n    at validateMember (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:45:21)\n    at validateList (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:60:12)\n    at validateMember (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:47:21)\n    at validateStructure (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:32:14)\n    at validateMember (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:45:21)\n    at validateStructure (/Users/andrewnarkewicz/Development/docs-attribution/node_modules/gulp-cloudfront/node_modules/aws-sdk/lib/param_validator.js:32:14)' }

Does not correctly match paths on windows systems.

On windows systems the options.dirRoot is not correctly resolved. file.base seems to use backslashes while file.path uses forward slash.

It seems the line:

options.dirRoot = options.dirRoot || file.base.replace(/\/$/, "");

Should be using:

options.dirRoot = options.dirRoot || file.base.replace(/[\/|\\]$/, "");

for it to run on windows.

Recommendation for deleting old files on s3?

I've got gulp-cloudfront working correctly, however, I'm wondering what the best way to remove the old files on s3 is, since every time I push code, I know have multiple copies of all the same files.

I'm using gulp-s3-ls, not gulp-awspublish (because gulp-awspublish wasn't working for buckets with periods in the name...)

Any suggestions?

Failures are not reported correctly

I am using this on a build server and this task always returns a successful status code, even when it has failed.

I believe the issue is that the task does not pass the error to the callback on failure

tool.updateDefaultRootObject(filename)
                .then(function() {
                    return callback(null, file);
                }, function(err) {
                    gutil.log(new gutil.PluginError('gulp-cloudfront', err));
                    callback(null, file); // Pass the error to the callback

                });

Bug: Cannot call method 'substr' of undefined

Sometimes when an object is deleted I get an error:

[13:26:07] [delete] bundle.3557797d.js

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot call method 'substr' of undefined
    at Transform._transform (/Users/me/Work/project/web/client/node_modules/gulp-cloudfront/index.js:21:34)

Gulp task:

gulp.task('deploy', function() {
  var publisher = awspublish.create(aws);
  var headers = {
     'Cache-Control': 'max-age=315360000, no-transform, public'
  };
  return gulp.src('./dist/**')
    .pipe(awspublish.gzip())
    .pipe(revall())
    .pipe(publisher.publish(headers))
    .pipe(publisher.sync())
    .pipe(publisher.cache())
    .pipe(awspublish.reporter())
    .pipe(cloudfront(aws));
});

Error: `Message: Cannot read property 'Bucket' of undefined`

Message:
    Cannot read property 'Bucket' of undefined

I'm getting this error message on execute.

const
  gulp = require( "gulp" ),
  awsPublish = require( "gulp-awspublish" ),                                   
  cloudfront = require( "gulp-cloudfront" ),
  aws = {
    key:"",
    secret: "",
    distributionId: "",
    bucket: "",
    region:""
  },
  envFlag = "dev";

gulp.task( "toS3:dev", () => {
  const publisher = awsPublish.create( aws );
  return gulp.src( "./src/dist/**" )             
    .pipe( awsPublish.gzip() )
    .pipe( publisher.publish( {
      "x-amz-acl": "public-read",
      "Cache-Control": ( envFlag === "prod" ? "max-age=3600" : "max-age=120" )
    }))              
    .pipe( publisher.cache() )
    .pipe( awsPublish.reporter() )
    .pipe( cloudfront( aws ) );
});

Removed files, now what?

Hey guys,

So I removed my files to try to upload it again to s3 using gulp-cloudfront, and now I'm busted.

I tried it a couple of times and it always says that my files are "cached" or "found". How do I clear all of it out and upload everything again in my bucket? I tried creating a new bucket, new cloudfront and it seems that the caching or mapping is somewhere in my PC.

Best Regards,

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.