smysnk / gulp-cloudfront Goto Github PK
View Code? Open in Web Editor NEWUpdates the Default Root Object of a CloudFront distribution
License: MIT License
Updates the Default Root Object of a CloudFront distribution
License: MIT License
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.
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.
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.
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 :).
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)' }
At https://github.com/smysnk/gulp-cloudfront/blob/master/index.js#L66 there's a reference to filePath.path
that isn't declared. Changing to file.path
fixes the problem.
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.
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?
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
});
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));
});
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 ) );
});
Is there a way to check first whether the Default Root Object has to be updated? So that, if there is the same value, do nothing.
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,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.