Permalink
Browse files

add some more examples

  • Loading branch information...
1 parent 3f31837 commit c4bb6cf2f3bc7b40b5d2c4484d1c2bb4e207448a @tellnes committed Apr 26, 2012
Showing with 54 additions and 0 deletions.
  1. +23 −0 examples/createDistribution.js
  2. +13 −0 examples/deleteDistribution.js
  3. +18 −0 examples/disableDistribution.js
@@ -0,0 +1,23 @@
+var cloudfront = require('..');
+
+var cf = cloudfront.createClient(process.env.AWS_KEY, process.env.AWS_SECRET);
+
+var config = {
+ originType: 'custom',
+ originDNSName: 'origin.example.com',
+ originProtocolPolicy: 'http-only',
+
+ cname: 'cdn.example.com',
+
+ comment: 'Example CDN',
+
+ enabled: true
+};
+
+cf.createDistribution(process.argv[2], config, function(err, oai) {
+ if (err) {
+ console.error(err);
+ } else {
+ console.log(oai);
+ }
+});
@@ -0,0 +1,13 @@
+var cloudfront = require('..');
+
+var cf = cloudfront.createClient(process.env.AWS_KEY, process.env.AWS_SECRET);
+
+cf.getDistribution(process.argv[2], function(err, dist) {
+ if (err) return console.error(err);
+
+ cf.deleteDistribution(dist.id, dist.etag, function(err) {
+ if (err) return console.error(err);
+
+ console.log('Deleted');
+ });
+});
@@ -0,0 +1,18 @@
+var cloudfront = require('..');
+
+var cf = cloudfront.createClient(process.env.AWS_KEY, process.env.AWS_SECRET);
+
+cf.getDistributionConfig(process.argv[2], function(err, config) {
+ if (err) throw err;
+
+ config.enabled = false;
+
+ console.log(config);
+ console.log(cf.generateDistributionXml(config));
+
+ cf.setDistributionConfig(process.argv[2], config, function(err, config2) {
+ if (err) throw err;
+
+ console.log(config2);
+ });
+});

0 comments on commit c4bb6cf

Please sign in to comment.