Example #1
0
 * POST    /api/medias              ->  create
 * GET     /api/medias/:id          ->  show
 * PUT     /api/medias/:id          ->  update
 * DELETE  /api/medias/:id          ->  destroy
 */

'use strict';

import _ from 'lodash';
import Media from './media.model';
const AWS = require('aws-sdk');
const fs = require('fs');
const config = require('../../config/environment');
import * as ut from '../../components/utils';

AWS.config.update({ region: 'eu-west-1' });
const s3 = new AWS.S3({ apiVersion: '2006-03-01' });

function handleError(res, statusCode) {
  statusCode = statusCode || 500;
  return function(err) {
    res.status(statusCode).send(err);
  };
}

function responseWithResult(res, statusCode) {
  statusCode = statusCode || 200;
  return function(entity) {
    if (entity) {
      res.status(statusCode).json(entity);
    }
Example #2
0
var Video = require('../models/video');
var Broadcast = require('../models/broadcast');
var OpenTok = require('opentok');
var AWS = require('aws-sdk');
var fs = require('fs');
var validator = require('validator');
var request = require('request');
var async = require('async');
var moment = require('moment');
var mailer = require('../config/mailer');
var dialog = require('../config/utils/dialog');
var uploader = require('../config/utils/uploader');
var request = require('request');
var config = require('../config');

AWS.config.update(config.aws.credens);
var s3Bucket = new AWS.S3();

var opentok = new OpenTok(config.openTok.key, config.openTok.secret);
var transporter = mailer.transporter();

exports.getVideoStatus = function(req, res, next) {

  var obj = {};

  Video.findOne({
    archiveId: req.params.archive_id
  }, function(err, video) {
    if (err) return next(err);
    if (!video || video.status !== 'uploaded') {
      obj.isReady = false;
Example #3
0
/**
 * Sets up connection into AWS
 *
 */
var CONFIG = require('config').api;
var AWS = require('aws-sdk');

// Load aws credentials and settings
AWS.config.update({accessKeyId: CONFIG.aws_accessKeyId, secretAccessKey: CONFIG.aws_secretAccessKey, region: CONFIG.aws_region});
AWS.config.apiVersions = {
    dynamodb: CONFIG.aws_DynamoDB_version
}

var dynamodb = new AWS.DynamoDB();

/**
 * Returns the dynamodb object
 */
exports.getDynamodb = function(){
    return dynamodb;
}
Example #4
0
  'cartodb.css',
  'cartodb.ie.css'
]

var CSS_IMAGE_FILES = fs.readdirSync('themes/css/images')
var IMG_FILES = fs.readdirSync('themes/img')

var content_type = {
  'png': 'image/png',
  'gif': 'image/gif',
  'css': 'text/css',
  'js': 'application/x-javascript'
};


AWS.config.update({ accessKeyId: secrets.S3_KEY, secretAccessKey: secrets.S3_SECRET });
var s3 = new AWS.S3({params: {Bucket: secrets.S3_BUCKET}});


//
// global flags
//

var only_invalidate = process.argv.length > 2 && process.argv[2] == '--invalidate';
var only_current_version = process.argv.length > 2 && process.argv[2] == '--current_version';
var version = 'v' + package_.version.split('.')[0];

/**
 * check that the remote file is the same than local one to avoid errors
 */
function check_file_upload(local, remote, done) {
Example #5
0
var AWS = require('aws-sdk');

AWS.config.update({region: 'us-west-2'});
console.log("AWS SDK Version=", JSON.stringify(AWS.VERSION));

AWS.config.getCredentials(useCredentials);

function useCredentials(err) {
	if(err) throw err;
	console.log("Credentials=", JSON.stringify(AWS.config.credentials));
	if(AWS.config.credentials != undefined) {
		console.log("SecretKey=", JSON.stringify(AWS.config.credentials.secretAccessKey));
	}
	var s3 = new AWS.S3();

	s3.getSignedUrl('getObject', {Bucket: 'test-bucket', Key: 'test-key'}, useSignedUrl);

	function useSignedUrl(err, url) {
		if(err) throw err;

		console.log("SignedUrl=", JSON.stringify(url));
	}

}
Example #6
0
var AWS = require('aws-sdk');
var fs = require('fs');
var path = require('path');

var region = 'us-west-2';
var bucket = 'fastpencildemo';
var s3Url = 'https://s3-' + region + '.amazonaws.com/' + bucket + '/';

AWS.config.update({
  accessKeyId: process.env.AWSAccessKeyId,
  secretAccessKey: process.env.AWSSecretKey,
  region: region
});

module.exports = {
  uploadFile: function(filePath, fn){
    fs.readFile(filePath, function (err, data) {
      if (err) { throw err; }

      var base64data = new Buffer(data, 'binary');
      var filename = path.basename(filePath);

      var s3 = new AWS.S3();
      s3.putObject({
        Bucket: bucket,
        Key: filename,
        Body: base64data,
        ACL: 'public-read'
      }, function(err, res){
        fn(err, {
          location: s3Url + filename
env(__dirname + '/.env');
var slack = {
    channelName: process.env['SLACK_CHANNEL_NAME'],
    incomingWebhookURL: process.env['SLACK_INCOMING_WEBHOOK_URL'],
    userName: process.env['SLACK_USER_NAME'],
    iconEmoji: process.env['SLACK_ICON_EMOJI']
};
var stackIds = {
    news:   process.env['STACK_ID_NEWS'],
    corp:   process.env['STACK_ID_CORP'],
    match:  process.env['STACK_ID_MATCH']
};

AWS.config.update({
    accessKeyId: process.env['CACHE_CLEANER_AWS_ACCESS_KEY_ID'],
    secretAccessKey: process.env['CACHE_CLEANER_AWS_SECRET_ACCESS_KEY'],
    region: 'us-east-1'
});
var opsworks = new AWS.OpsWorks();

exports.handler = function(event, context) {

    console.log('Event received, ', new Date());
    console.log('event: ', event);

    var stackId = '';
    if (/clean news/.test(event.text)) {
        stackId = stackIds.news;
    } else if (/clean corp/.test(event.text)) {
        stackId = stackIds.corp;
    } else if (/clean match/.test(event.text)) {
Example #8
0
var nano = require('nano')('http://127.0.0.1:5984'),
    institutions_db = nano.use('institutions'),
    users_db = nano.use('_users'),
    AWS = require('aws-sdk'),
    crypto = require('crypto'),
    fs = require('fs');

var adminCreds = require('../couchcreds.json'),
    adminNano = require('nano')('http://127.0.0.1:5984'),
    adminUsers_db = adminNano.use('_users');

// Configure admin nano
adminNano.config.url = 'http://' + adminCreds.user + ':' + adminCreds.pass + '@127.0.0.1:5984';

// Configure AWS
AWS.config.loadFromPath('./AWScredentials.json');

// Registration method
exports.register = function(req, res) {
    var username = req.body.username,
        password = req.body.password,
        first = req.body.first,
        last = req.body.last,
        institution = req.body.institution,
        email = req.body.email,
        phone = req.body.phone;

    try {
        var buffer = crypto.randomBytes(256);
        var i;
        var verificationCode = '';
Example #9
0
var fs = require('fs');
var AWS = require('aws-sdk');

// Environment Variables
var warFile = process.env.KNL_API_WAR || "kornell-api/kornell-api.war";
var asgName = process.env.KNL_ASG_NAME || "kornell-api-test-asg";
var skipUpload = (process.env.KNL_SKIP_UP == "true");
var waitTimeout = parseInt(process.env.KNL_WAIT_TIMEOUT) || 300;
var waitStep = parseInt(process.env.KNL_WAIT_STEP) || 20;

AWS.config.update({
	region : 'sa-east-1',
	logger : process.stdout
});

var warBucket = "dist-sa-east-1.craftware.com";
var warKey = "Kornell/kornell-api.war"
var asgUpPolicy = "double"
var asgDownPolicy = "half"

var s3 = new AWS.S3();
var asg = new AWS.AutoScaling();
var elb = new AWS.ELB();

function knot() {
	console.log("Finishing...")
	setTimeout(function() {
		console.log('Bye!');
		process.exit();
	}, 1000);
}
Example #10
0
//initialize all the required libraries and connections
var express = require('express'),
    app = express(),
    http = require('http'),
    socketIo = require('socket.io'),
    aws = require('aws-sdk');
var server = http.createServer(app);
var io = socketIo.listen(server);
var port = process.env.PORT || 8080;
var accessKeyId =  process.env.AWS_ACCESS_KEY || "xxxxxx";
var secretAccessKey = process.env.AWS_SECRET_KEY || "xxxxxx";
var s3bucket = process.env.S3_BUCKET || "xx-xx-xx-xx";

//configure the aws account information to be used
aws.config.update({
    accessKeyId: accessKeyId,
    secretAccessKey: secretAccessKey
});
//set the desired s3 bucket to use
var s3 = new aws.S3({
      params: {Bucket: s3bucket}
});
//start the application
server.listen(port);
app.use(express.static(__dirname + '/public'));
console.log("Server running on 127.0.0.1:" + port);
//historical data and counter for image names
var lineHistory = [];
var messageHistory = [];
var counter = 0;
//on successful connection from client to server
io.on('connection', function (socket) {
Example #11
0
// load aws sdk
var aws = require('aws-sdk');

// load aws config
aws.config.loadFromPath('config.json'); //load here access key and secret key or configure them on process.env

// load AWS SES
var ses = new aws.SES({apiVersion: '2010-12-01'});//yes, need to set the version

// send to list
var to = ['guy@domain.com'];

// this must relate to a verified SES account
var from = 'meh@gmail.com';

// this sends the email
// @todo - add HTML version
ses.sendEmail( 
	{ 
		Source: from, 
		Destination: { ToAddresses: to },
		Message: {
			Subject: {
				Data: 'This is a message'
			},
			Body: {
				Text: {
					Data: 'Behe hehhehe',
				}
			}
		}
var args = require('minimist')(process.argv);
var AWS = require('aws-sdk');
var fs = require('fs');
var awsS3Client = new AWS.S3();
var s3Stream = require('s3-upload-stream')(awsS3Client);


console.log("Arguments: ");
console.dir(args);
console.log("Uplading file: " + args.file);

AWS.config.update({region: 'us-west-2'});

var read = fs.createReadStream(args.file);
var upload = s3Stream.upload({
    Bucket: args.s3Bucket,
    Key: args.s3Key
});

upload.maxPartSize(20 * 1024 * 1024); // 20 MB
upload.concurrentParts(10);

upload.on('error', function (error) {
    console.log('error');
    console.error(error);
});

var megabate = 1024 * 1024;

upload.on('part', function (details) {
    var receivedSize = (details.receivedSize / megabate);
Example #13
0
	function AmazonAPINode(n) {
		RED.nodes.createNode(this,n);
		this.awsConfig = RED.nodes.getNode(n.aws);
		this.region = n.region;
		this.operation = n.operation;
		this.name = n.name;
		this.region = this.awsConfig.region;
		this.accessKey = this.awsConfig.accessKey;
		this.secretKey = this.awsConfig.secretKey;

		var node = this;
		var AWS = require("aws-sdk");
		AWS.config.update({
			accessKeyId: this.accessKey,
			secretAccessKey: this.secretKey,
			region: this.region
		});
		if (!AWS) {
			node.warn("Missing AWS credentials");
			return;
		}

        if (this.awsConfig.proxyRequired){
            var proxy = require('proxy-agent');
            AWS.config.update({
                httpOptions: { agent: new proxy(this.awsConfig.proxy) }
            });
        }

		var awsService = new AWS.Redshift( { 'region': node.region } );

		node.on("input", function(msg) {
			node.sendMsg = function (err, data) {
				if (err) {
				    node.status({fill:"red",shape:"ring",text:"error"});
                    node.error("failed: " + err.toString(), msg);
                    node.send([null, { err: err }]);
    				return;
				} else {
				msg.payload = data;
				node.status({});
				}
				node.send([msg,null]);
			};
		
			var _cb=function(err,data){
				node.sendMsg(err,data);
			}		

			if (typeof service[node.operation] == "function"){
				node.status({fill:"blue",shape:"dot",text:node.operation});
				service[node.operation](awsService,msg,_cb);
			} else {
				node.error("failed: Operation node defined - "+node.operation);
			}

		});
		var copyArg=function(src,arg,out,outArg,isObject){
			var tmpValue=src[arg];
			outArg = (typeof outArg !== 'undefined') ? outArg : arg;

			if (typeof src[arg] !== 'undefined'){
				if (isObject && typeof src[arg]=="string" && src[arg] != "") { 
					tmpValue=JSON.parse(src[arg]);
				}
				out[outArg]=tmpValue;
			}
                        //AWS API takes 'Payload' not 'payload' (see Lambda)
                        if (arg=="Payload" && typeof tmpValue == 'undefined'){
                                out[arg]=src["payload"];
                        }

		}

		var service={};

		
		service.AcceptReservedNodeExchange=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ReservedNodeId",params,undefined,false); 
			copyArg(n,"TargetReservedNodeOfferingId",params,undefined,false); 
			
			copyArg(msg,"ReservedNodeId",params,undefined,false); 
			copyArg(msg,"TargetReservedNodeOfferingId",params,undefined,false); 
			

			svc.acceptReservedNodeExchange(params,cb);
		}

		
		service.AuthorizeClusterSecurityGroupIngress=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSecurityGroupName",params,undefined,false); 
			
			copyArg(msg,"ClusterSecurityGroupName",params,undefined,false); 
			copyArg(msg,"CIDRIP",params,undefined,false); 
			copyArg(msg,"EC2SecurityGroupName",params,undefined,false); 
			copyArg(msg,"EC2SecurityGroupOwnerId",params,undefined,false); 
			

			svc.authorizeClusterSecurityGroupIngress(params,cb);
		}

		
		service.AuthorizeSnapshotAccess=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SnapshotIdentifier",params,undefined,false); 
			copyArg(n,"AccountWithRestoreAccess",params,undefined,false); 
			
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotClusterIdentifier",params,undefined,false); 
			copyArg(msg,"AccountWithRestoreAccess",params,undefined,false); 
			

			svc.authorizeSnapshotAccess(params,cb);
		}

		
		service.CopyClusterSnapshot=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SourceSnapshotIdentifier",params,undefined,false); 
			copyArg(n,"TargetSnapshotIdentifier",params,undefined,false); 
			
			copyArg(msg,"SourceSnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SourceSnapshotClusterIdentifier",params,undefined,false); 
			copyArg(msg,"TargetSnapshotIdentifier",params,undefined,false); 
			

			svc.copyClusterSnapshot(params,cb);
		}

		
		service.CreateCluster=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"NodeType",params,undefined,false); 
			copyArg(n,"MasterUsername",params,undefined,false); 
			copyArg(n,"MasterUserPassword",params,undefined,false); 
			
			copyArg(msg,"DBName",params,undefined,false); 
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"ClusterType",params,undefined,false); 
			copyArg(msg,"NodeType",params,undefined,false); 
			copyArg(msg,"MasterUsername",params,undefined,false); 
			copyArg(msg,"MasterUserPassword",params,undefined,false); 
			copyArg(msg,"ClusterSecurityGroups",params,undefined,true); 
			copyArg(msg,"VpcSecurityGroupIds",params,undefined,true); 
			copyArg(msg,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(msg,"AvailabilityZone",params,undefined,false); 
			copyArg(msg,"PreferredMaintenanceWindow",params,undefined,false); 
			copyArg(msg,"ClusterParameterGroupName",params,undefined,false); 
			copyArg(msg,"AutomatedSnapshotRetentionPeriod",params,undefined,false); 
			copyArg(msg,"Port",params,undefined,false); 
			copyArg(msg,"ClusterVersion",params,undefined,false); 
			copyArg(msg,"AllowVersionUpgrade",params,undefined,false); 
			copyArg(msg,"NumberOfNodes",params,undefined,false); 
			copyArg(msg,"PubliclyAccessible",params,undefined,false); 
			copyArg(msg,"Encrypted",params,undefined,false); 
			copyArg(msg,"HsmClientCertificateIdentifier",params,undefined,false); 
			copyArg(msg,"HsmConfigurationIdentifier",params,undefined,false); 
			copyArg(msg,"ElasticIp",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			copyArg(msg,"KmsKeyId",params,undefined,false); 
			copyArg(msg,"EnhancedVpcRouting",params,undefined,false); 
			copyArg(msg,"AdditionalInfo",params,undefined,false); 
			copyArg(msg,"IamRoles",params,undefined,true); 
			copyArg(msg,"MaintenanceTrackName",params,undefined,false); 
			

			svc.createCluster(params,cb);
		}

		
		service.CreateClusterParameterGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ParameterGroupName",params,undefined,false); 
			copyArg(n,"ParameterGroupFamily",params,undefined,false); 
			copyArg(n,"Description",params,undefined,false); 
			
			copyArg(msg,"ParameterGroupName",params,undefined,false); 
			copyArg(msg,"ParameterGroupFamily",params,undefined,false); 
			copyArg(msg,"Description",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createClusterParameterGroup(params,cb);
		}

		
		service.CreateClusterSecurityGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSecurityGroupName",params,undefined,false); 
			copyArg(n,"Description",params,undefined,false); 
			
			copyArg(msg,"ClusterSecurityGroupName",params,undefined,false); 
			copyArg(msg,"Description",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createClusterSecurityGroup(params,cb);
		}

		
		service.CreateClusterSnapshot=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SnapshotIdentifier",params,undefined,false); 
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createClusterSnapshot(params,cb);
		}

		
		service.CreateClusterSubnetGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(n,"Description",params,undefined,false); 
			copyArg(n,"SubnetIds",params,undefined,true); 
			
			copyArg(msg,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(msg,"Description",params,undefined,false); 
			copyArg(msg,"SubnetIds",params,undefined,true); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createClusterSubnetGroup(params,cb);
		}

		
		service.CreateEventSubscription=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SubscriptionName",params,undefined,false); 
			copyArg(n,"SnsTopicArn",params,undefined,false); 
			
			copyArg(msg,"SubscriptionName",params,undefined,false); 
			copyArg(msg,"SnsTopicArn",params,undefined,false); 
			copyArg(msg,"SourceType",params,undefined,false); 
			copyArg(msg,"SourceIds",params,undefined,true); 
			copyArg(msg,"EventCategories",params,undefined,true); 
			copyArg(msg,"Severity",params,undefined,false); 
			copyArg(msg,"Enabled",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createEventSubscription(params,cb);
		}

		
		service.CreateHsmClientCertificate=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"HsmClientCertificateIdentifier",params,undefined,false); 
			
			copyArg(msg,"HsmClientCertificateIdentifier",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createHsmClientCertificate(params,cb);
		}

		
		service.CreateHsmConfiguration=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"HsmConfigurationIdentifier",params,undefined,false); 
			copyArg(n,"Description",params,undefined,false); 
			copyArg(n,"HsmIpAddress",params,undefined,false); 
			copyArg(n,"HsmPartitionName",params,undefined,false); 
			copyArg(n,"HsmPartitionPassword",params,undefined,false); 
			copyArg(n,"HsmServerPublicCertificate",params,undefined,false); 
			
			copyArg(msg,"HsmConfigurationIdentifier",params,undefined,false); 
			copyArg(msg,"Description",params,undefined,false); 
			copyArg(msg,"HsmIpAddress",params,undefined,false); 
			copyArg(msg,"HsmPartitionName",params,undefined,false); 
			copyArg(msg,"HsmPartitionPassword",params,undefined,false); 
			copyArg(msg,"HsmServerPublicCertificate",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createHsmConfiguration(params,cb);
		}

		
		service.CreateSnapshotCopyGrant=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SnapshotCopyGrantName",params,undefined,false); 
			
			copyArg(msg,"SnapshotCopyGrantName",params,undefined,false); 
			copyArg(msg,"KmsKeyId",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createSnapshotCopyGrant(params,cb);
		}

		
		service.CreateTags=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ResourceName",params,undefined,false); 
			copyArg(n,"Tags",params,undefined,true); 
			
			copyArg(msg,"ResourceName",params,undefined,false); 
			copyArg(msg,"Tags",params,undefined,true); 
			

			svc.createTags(params,cb);
		}

		
		service.DeleteCluster=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"SkipFinalClusterSnapshot",params,undefined,false); 
			copyArg(msg,"FinalClusterSnapshotIdentifier",params,undefined,false); 
			

			svc.deleteCluster(params,cb);
		}

		
		service.DeleteClusterParameterGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ParameterGroupName",params,undefined,false); 
			
			copyArg(msg,"ParameterGroupName",params,undefined,false); 
			

			svc.deleteClusterParameterGroup(params,cb);
		}

		
		service.DeleteClusterSecurityGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSecurityGroupName",params,undefined,false); 
			
			copyArg(msg,"ClusterSecurityGroupName",params,undefined,false); 
			

			svc.deleteClusterSecurityGroup(params,cb);
		}

		
		service.DeleteClusterSnapshot=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SnapshotIdentifier",params,undefined,false); 
			
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotClusterIdentifier",params,undefined,false); 
			

			svc.deleteClusterSnapshot(params,cb);
		}

		
		service.DeleteClusterSubnetGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSubnetGroupName",params,undefined,false); 
			
			copyArg(msg,"ClusterSubnetGroupName",params,undefined,false); 
			

			svc.deleteClusterSubnetGroup(params,cb);
		}

		
		service.DeleteEventSubscription=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SubscriptionName",params,undefined,false); 
			
			copyArg(msg,"SubscriptionName",params,undefined,false); 
			

			svc.deleteEventSubscription(params,cb);
		}

		
		service.DeleteHsmClientCertificate=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"HsmClientCertificateIdentifier",params,undefined,false); 
			
			copyArg(msg,"HsmClientCertificateIdentifier",params,undefined,false); 
			

			svc.deleteHsmClientCertificate(params,cb);
		}

		
		service.DeleteHsmConfiguration=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"HsmConfigurationIdentifier",params,undefined,false); 
			
			copyArg(msg,"HsmConfigurationIdentifier",params,undefined,false); 
			

			svc.deleteHsmConfiguration(params,cb);
		}

		
		service.DeleteSnapshotCopyGrant=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SnapshotCopyGrantName",params,undefined,false); 
			
			copyArg(msg,"SnapshotCopyGrantName",params,undefined,false); 
			

			svc.deleteSnapshotCopyGrant(params,cb);
		}

		
		service.DeleteTags=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ResourceName",params,undefined,false); 
			copyArg(n,"TagKeys",params,undefined,true); 
			
			copyArg(msg,"ResourceName",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			

			svc.deleteTags(params,cb);
		}

		
		service.DescribeClusterDbRevisions=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeClusterDbRevisions(params,cb);
		}

		
		service.DescribeClusterParameterGroups=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ParameterGroupName",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeClusterParameterGroups(params,cb);
		}

		
		service.DescribeClusterParameters=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ParameterGroupName",params,undefined,false); 
			
			copyArg(msg,"ParameterGroupName",params,undefined,false); 
			copyArg(msg,"Source",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeClusterParameters(params,cb);
		}

		
		service.DescribeClusterSecurityGroups=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterSecurityGroupName",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeClusterSecurityGroups(params,cb);
		}

		
		service.DescribeClusterSnapshots=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotType",params,undefined,false); 
			copyArg(msg,"StartTime",params,undefined,false); 
			copyArg(msg,"EndTime",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"OwnerAccount",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			copyArg(msg,"ClusterExists",params,undefined,false); 
			

			svc.describeClusterSnapshots(params,cb);
		}

		
		service.DescribeClusterSubnetGroups=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeClusterSubnetGroups(params,cb);
		}

		
		service.DescribeClusterTracks=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"MaintenanceTrackName",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeClusterTracks(params,cb);
		}

		
		service.DescribeClusterVersions=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterVersion",params,undefined,false); 
			copyArg(msg,"ClusterParameterGroupFamily",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeClusterVersions(params,cb);
		}

		
		service.DescribeClusters=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeClusters(params,cb);
		}

		
		service.DescribeDefaultClusterParameters=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ParameterGroupFamily",params,undefined,false); 
			
			copyArg(msg,"ParameterGroupFamily",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeDefaultClusterParameters(params,cb);
		}

		
		service.DescribeEventCategories=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"SourceType",params,undefined,false); 
			

			svc.describeEventCategories(params,cb);
		}

		
		service.DescribeEventSubscriptions=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"SubscriptionName",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeEventSubscriptions(params,cb);
		}

		
		service.DescribeEvents=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"SourceIdentifier",params,undefined,false); 
			copyArg(msg,"SourceType",params,undefined,false); 
			copyArg(msg,"StartTime",params,undefined,false); 
			copyArg(msg,"EndTime",params,undefined,false); 
			copyArg(msg,"Duration",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeEvents(params,cb);
		}

		
		service.DescribeHsmClientCertificates=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"HsmClientCertificateIdentifier",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeHsmClientCertificates(params,cb);
		}

		
		service.DescribeHsmConfigurations=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"HsmConfigurationIdentifier",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeHsmConfigurations(params,cb);
		}

		
		service.DescribeLoggingStatus=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			

			svc.describeLoggingStatus(params,cb);
		}

		
		service.DescribeOrderableClusterOptions=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterVersion",params,undefined,false); 
			copyArg(msg,"NodeType",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeOrderableClusterOptions(params,cb);
		}

		
		service.DescribeReservedNodeOfferings=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ReservedNodeOfferingId",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeReservedNodeOfferings(params,cb);
		}

		
		service.DescribeReservedNodes=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ReservedNodeId",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeReservedNodes(params,cb);
		}

		
		service.DescribeResize=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			

			svc.describeResize(params,cb);
		}

		
		service.DescribeSnapshotCopyGrants=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"SnapshotCopyGrantName",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeSnapshotCopyGrants(params,cb);
		}

		
		service.DescribeTableRestoreStatus=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"TableRestoreRequestId",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.describeTableRestoreStatus(params,cb);
		}

		
		service.DescribeTags=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			
			copyArg(msg,"ResourceName",params,undefined,false); 
			copyArg(msg,"ResourceType",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			copyArg(msg,"TagKeys",params,undefined,true); 
			copyArg(msg,"TagValues",params,undefined,true); 
			

			svc.describeTags(params,cb);
		}

		
		service.DisableLogging=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			

			svc.disableLogging(params,cb);
		}

		
		service.DisableSnapshotCopy=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			

			svc.disableSnapshotCopy(params,cb);
		}

		
		service.EnableLogging=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"BucketName",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"BucketName",params,undefined,false); 
			copyArg(msg,"S3KeyPrefix",params,undefined,false); 
			

			svc.enableLogging(params,cb);
		}

		
		service.EnableSnapshotCopy=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"DestinationRegion",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"DestinationRegion",params,undefined,false); 
			copyArg(msg,"RetentionPeriod",params,undefined,false); 
			copyArg(msg,"SnapshotCopyGrantName",params,undefined,false); 
			

			svc.enableSnapshotCopy(params,cb);
		}

		
		service.GetClusterCredentials=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"DbUser",params,undefined,false); 
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"DbUser",params,undefined,false); 
			copyArg(msg,"DbName",params,undefined,false); 
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"DurationSeconds",params,undefined,false); 
			copyArg(msg,"AutoCreate",params,undefined,false); 
			copyArg(msg,"DbGroups",params,undefined,false); 
			

			svc.getClusterCredentials(params,cb);
		}

		
		service.GetReservedNodeExchangeOfferings=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ReservedNodeId",params,undefined,false); 
			
			copyArg(msg,"ReservedNodeId",params,undefined,false); 
			copyArg(msg,"MaxRecords",params,undefined,false); 
			copyArg(msg,"Marker",params,undefined,false); 
			

			svc.getReservedNodeExchangeOfferings(params,cb);
		}

		
		service.ModifyCluster=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"ClusterType",params,undefined,false); 
			copyArg(msg,"NodeType",params,undefined,false); 
			copyArg(msg,"NumberOfNodes",params,undefined,false); 
			copyArg(msg,"ClusterSecurityGroups",params,undefined,true); 
			copyArg(msg,"VpcSecurityGroupIds",params,undefined,true); 
			copyArg(msg,"MasterUserPassword",params,undefined,false); 
			copyArg(msg,"ClusterParameterGroupName",params,undefined,false); 
			copyArg(msg,"AutomatedSnapshotRetentionPeriod",params,undefined,false); 
			copyArg(msg,"PreferredMaintenanceWindow",params,undefined,false); 
			copyArg(msg,"ClusterVersion",params,undefined,false); 
			copyArg(msg,"AllowVersionUpgrade",params,undefined,false); 
			copyArg(msg,"HsmClientCertificateIdentifier",params,undefined,false); 
			copyArg(msg,"HsmConfigurationIdentifier",params,undefined,false); 
			copyArg(msg,"NewClusterIdentifier",params,undefined,false); 
			copyArg(msg,"PubliclyAccessible",params,undefined,false); 
			copyArg(msg,"ElasticIp",params,undefined,false); 
			copyArg(msg,"EnhancedVpcRouting",params,undefined,false); 
			copyArg(msg,"MaintenanceTrackName",params,undefined,false); 
			copyArg(msg,"Encrypted",params,undefined,false); 
			copyArg(msg,"KmsKeyId",params,undefined,false); 
			

			svc.modifyCluster(params,cb);
		}

		
		service.ModifyClusterDbRevision=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"RevisionTarget",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"RevisionTarget",params,undefined,false); 
			

			svc.modifyClusterDbRevision(params,cb);
		}

		
		service.ModifyClusterIamRoles=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"AddIamRoles",params,undefined,true); 
			copyArg(msg,"RemoveIamRoles",params,undefined,true); 
			

			svc.modifyClusterIamRoles(params,cb);
		}

		
		service.ModifyClusterParameterGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ParameterGroupName",params,undefined,false); 
			copyArg(n,"Parameters",params,undefined,true); 
			
			copyArg(msg,"ParameterGroupName",params,undefined,false); 
			copyArg(msg,"Parameters",params,undefined,true); 
			

			svc.modifyClusterParameterGroup(params,cb);
		}

		
		service.ModifyClusterSubnetGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(n,"SubnetIds",params,undefined,true); 
			
			copyArg(msg,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(msg,"Description",params,undefined,false); 
			copyArg(msg,"SubnetIds",params,undefined,true); 
			

			svc.modifyClusterSubnetGroup(params,cb);
		}

		
		service.ModifyEventSubscription=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SubscriptionName",params,undefined,false); 
			
			copyArg(msg,"SubscriptionName",params,undefined,false); 
			copyArg(msg,"SnsTopicArn",params,undefined,false); 
			copyArg(msg,"SourceType",params,undefined,false); 
			copyArg(msg,"SourceIds",params,undefined,true); 
			copyArg(msg,"EventCategories",params,undefined,true); 
			copyArg(msg,"Severity",params,undefined,false); 
			copyArg(msg,"Enabled",params,undefined,false); 
			

			svc.modifyEventSubscription(params,cb);
		}

		
		service.ModifySnapshotCopyRetentionPeriod=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"RetentionPeriod",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"RetentionPeriod",params,undefined,false); 
			

			svc.modifySnapshotCopyRetentionPeriod(params,cb);
		}

		
		service.PurchaseReservedNodeOffering=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ReservedNodeOfferingId",params,undefined,false); 
			
			copyArg(msg,"ReservedNodeOfferingId",params,undefined,false); 
			copyArg(msg,"NodeCount",params,undefined,false); 
			

			svc.purchaseReservedNodeOffering(params,cb);
		}

		
		service.RebootCluster=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			

			svc.rebootCluster(params,cb);
		}

		
		service.ResetClusterParameterGroup=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ParameterGroupName",params,undefined,false); 
			
			copyArg(msg,"ParameterGroupName",params,undefined,false); 
			copyArg(msg,"ResetAllParameters",params,undefined,false); 
			copyArg(msg,"Parameters",params,undefined,true); 
			

			svc.resetClusterParameterGroup(params,cb);
		}

		
		service.ResizeCluster=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"NumberOfNodes",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"ClusterType",params,undefined,false); 
			copyArg(msg,"NodeType",params,undefined,false); 
			copyArg(msg,"NumberOfNodes",params,undefined,false); 
			copyArg(msg,"Classic",params,undefined,false); 
			

			svc.resizeCluster(params,cb);
		}

		
		service.RestoreFromClusterSnapshot=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"SnapshotIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotClusterIdentifier",params,undefined,false); 
			copyArg(msg,"Port",params,undefined,false); 
			copyArg(msg,"AvailabilityZone",params,undefined,false); 
			copyArg(msg,"AllowVersionUpgrade",params,undefined,false); 
			copyArg(msg,"ClusterSubnetGroupName",params,undefined,false); 
			copyArg(msg,"PubliclyAccessible",params,undefined,false); 
			copyArg(msg,"OwnerAccount",params,undefined,false); 
			copyArg(msg,"HsmClientCertificateIdentifier",params,undefined,false); 
			copyArg(msg,"HsmConfigurationIdentifier",params,undefined,false); 
			copyArg(msg,"ElasticIp",params,undefined,false); 
			copyArg(msg,"ClusterParameterGroupName",params,undefined,false); 
			copyArg(msg,"ClusterSecurityGroups",params,undefined,true); 
			copyArg(msg,"VpcSecurityGroupIds",params,undefined,true); 
			copyArg(msg,"PreferredMaintenanceWindow",params,undefined,false); 
			copyArg(msg,"AutomatedSnapshotRetentionPeriod",params,undefined,false); 
			copyArg(msg,"KmsKeyId",params,undefined,false); 
			copyArg(msg,"NodeType",params,undefined,false); 
			copyArg(msg,"EnhancedVpcRouting",params,undefined,false); 
			copyArg(msg,"AdditionalInfo",params,undefined,false); 
			copyArg(msg,"IamRoles",params,undefined,true); 
			copyArg(msg,"MaintenanceTrackName",params,undefined,false); 
			

			svc.restoreFromClusterSnapshot(params,cb);
		}

		
		service.RestoreTableFromClusterSnapshot=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			copyArg(n,"SnapshotIdentifier",params,undefined,false); 
			copyArg(n,"SourceDatabaseName",params,undefined,false); 
			copyArg(n,"SourceTableName",params,undefined,false); 
			copyArg(n,"NewTableName",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SourceDatabaseName",params,undefined,false); 
			copyArg(msg,"SourceSchemaName",params,undefined,false); 
			copyArg(msg,"SourceTableName",params,undefined,false); 
			copyArg(msg,"TargetDatabaseName",params,undefined,false); 
			copyArg(msg,"TargetSchemaName",params,undefined,false); 
			copyArg(msg,"NewTableName",params,undefined,false); 
			

			svc.restoreTableFromClusterSnapshot(params,cb);
		}

		
		service.RevokeClusterSecurityGroupIngress=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterSecurityGroupName",params,undefined,false); 
			
			copyArg(msg,"ClusterSecurityGroupName",params,undefined,false); 
			copyArg(msg,"CIDRIP",params,undefined,false); 
			copyArg(msg,"EC2SecurityGroupName",params,undefined,false); 
			copyArg(msg,"EC2SecurityGroupOwnerId",params,undefined,false); 
			

			svc.revokeClusterSecurityGroupIngress(params,cb);
		}

		
		service.RevokeSnapshotAccess=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"SnapshotIdentifier",params,undefined,false); 
			copyArg(n,"AccountWithRestoreAccess",params,undefined,false); 
			
			copyArg(msg,"SnapshotIdentifier",params,undefined,false); 
			copyArg(msg,"SnapshotClusterIdentifier",params,undefined,false); 
			copyArg(msg,"AccountWithRestoreAccess",params,undefined,false); 
			

			svc.revokeSnapshotAccess(params,cb);
		}

		
		service.RotateEncryptionKey=function(svc,msg,cb){
			var params={};
			//copyArgs
			
			copyArg(n,"ClusterIdentifier",params,undefined,false); 
			
			copyArg(msg,"ClusterIdentifier",params,undefined,false); 
			

			svc.rotateEncryptionKey(params,cb);
		}

			

	}
Example #14
0
// CONSTANTS
kmsEncyptedToken = "CiC+t+IKhbKCLUSP834vDZu8SAXPw/hqnLXIwOC0rEB2tBKxAQEBAgB4vrfiCoWygi1Ej/N+Lw2bvEgFz8P4apy1yMDgtKxAdrQAAACIMIGFBgkqhkiG9w0BBwageDB2AgEAMHEGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMvha/ptFPUWrX3deyAgEQgEQ/iPzB+w7vklx/j1WIP9qGGiJpTprxziRAu9QTfAtfscyo+PEOHlc1W1ARMvvetGBhkDLBzZOA7L9uuSltsdkOOAOYRQ==";

// JavaScript source code
var AWS = require('aws-sdk');
var qs = require('querystring');
var token, kmsEncyptedToken;
var RtmClient = require('@slack/client').RtmClient;
var RTM_EVENTS = require('@slack/client').RTM_EVENTS;
var RTM_CLIENT_EVENTS = require('@slack/client').CLIENT_EVENTS.RTM;

// Ensure that the region is correct
AWS.config.update({
    region:'ap-southeast-1'
});

// Set the API version for SNS
AWS.config.apiVersions = {
    sns: '2010-03-31',
    // other service API versions
};

// Publish the message that Nayya recieves to the topic
function publishMsgToTopic (msg, topicID) {
        var msgParams = {
            Message: msg,
            TopicArn: topicID
        };
        
        // Publish the chat msg on the specified Topic
        snsClient.publish(msgParams, function(err, data){
Example #15
0
//good example: https://github.com/samccone/White-Board/blob/master/app.js
/*
Handles Status and Statuses
*/

var fs = require("fs");
var request = require('request');

var AWS = require('aws-sdk');
AWS.config.update({
    accessKeyId: 'AKIAI76FORJPOUF3FXIA',
    secretAccessKey: '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'
});
AWS.config.update({
    region: 'us-west-2'
});
var s3bucket = new AWS.S3({
    params: {
        Bucket: 'artoffx'
    }
});

module.exports = function(io, pool) {

    return {
        saveOne: function(res, req) {
            var self = this
            var values = req.body

            pool.getConnection(function(err, connection) {
                values = self.deleteDisplayValues(values)
Example #16
0
  grunt.registerMultiTask("s3", DESC, function() {

    //normalize files array (force expand)
    var files = [];
    this.files.forEach(function(file) {
      var cwd = file.cwd || '';
      files = files.concat(file.src.map(function(src) {
        var s = path.join(cwd, src),
            d = (cwd||file.src.length>1) ? ((file.dest||'')+src) : file.dest || src;
        return {src: s, dest: d};
      }));
    });

    //skip directories since there are only files on s3
    files = files.filter(function(file) {
      return !grunt.file.isDir(file.src);
    });

    if(!files.length)
      return grunt.log.ok("No files matched");

    //mark as async
    var done = this.async();
    //get options
    var opts = this.options(DEFAULTS);

    //checks
    if(!opts.bucket)
      grunt.fail.warn("No 'bucket' has been specified");

    //custom mime types
    if(typeof opts.mime === 'object')
      mime.define(opts.mime);
    if(typeof opts.mimeDefault === 'string')
      mime.default_type = opts.mimeDefault;

    //whitelist allowed keys
    AWS.config.update(_.pick(opts,
      'accessKeyId',
      'secretAccessKey',
      'region',
      'sslEnabled',
      'maxRetries',
      'httpOptions'
    ), true);

    //s3 client
    var S3 = new AWS.S3();

    //dry run prefix
    var DRYRUN = opts.dryRun ? "[DRYRUN] " : "";

    //retrieve cache for this bucket
    var cache = CacheMgr.get(opts.bucket);

    if(!cache.options)
      cache.options = {};
    if(!cache.prefixes)
      cache.prefixes = {};
    if(!cache.files)
      cache.files = {};

    //base object (lacks Body and Key)
    var baseObject = {
      ACL: opts.access,
      Bucket: opts.bucket
    };

    //set gzip encoding
    if(opts.gzip)
      baseObject.ContentEncoding = 'gzip';

    //use allowed headers
    if(typeof opts.headers === 'object')
      _.extend(baseObject, _.pick(
        opts.headers,
        //http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property
        'ContentLength',
        'ContentType',
        'ContentDisposition',
        'ContentEncoding',
        'CacheControl',
        'Expires',
        'GrantFullControl',
        'GrantRead',
        'GrantReadACP',
        'GrantWriteACP',
        'ServerSideEncryption',
        'StorageClass',
        'WebsiteRedirectLocation'
      ));

    //convert numbers and dates
    if(typeof baseObject.CacheControl === 'number')
      baseObject.CacheControl = "max-age="+baseObject.CacheControl+", public";
    else if (typeof baseObject.CacheControl === 'object') {
      var val = baseObject.CacheControl,
          maxage = val.MaxAge || null,
          swr = val.StaleWhileRevalidate || null;
      if (!maxage) {
        grunt.fail.warn("max_age is required for Cache-Control header");
      }
      if (swr) {
        baseObject.CacheControl = "max-age="+maxage+", stale-while-revalidate="+swr+", public";
      } else {
        baseObject.CacheControl = "max-age="+maxage+", public";
      }
    }

    if(baseObject.Expires instanceof Date)
      baseObject.Expires = baseObject.Expires.toUTCString();

    //use meta data headers
    if(typeof opts.meta === 'object')
      baseObject.Metadata = opts.meta;

    //calculate options hash
    var optionsHash = hash(JSON.stringify(baseObject), 'sha256');
    var currOptionsHash = cache.options[this.target];

    //maintain stats
    var stats = { puts: 0, dels: 0, refreshed: false, newOptions: optionsHash !== currOptionsHash };

    if(stats.newOptions)
      cache.options[this.target] = optionsHash;

    var subtasks = [];

    //create the bucket if it does not exist
    if(opts.createBucket)
      subtasks.push(createBucket);

    //enable webhosting
    if(opts.enableWeb)
      subtasks.push(enableWebHosting);

    if(!opts.cache)
      subtasks.push(getFileList);

    subtasks.push(copyAllFiles);

    //start!
    async.series(subtasks, taskComplete);

    //------------------------------------------------

    function createBucket(callback) {
      //check the bucket doesn't exist first
      S3.listBuckets(function(err, data){
        if(err) return callback(err);
        var existingBucket = _.detect(data.Buckets, function(bucket){
          return opts.bucket === bucket.Name;
        });
        if(existingBucket){
          grunt.log.writeln('Existing bucket found.');
          callback();
        }else{
          grunt.log.writeln('Creating bucket ' + opts.bucket + '...');
          //create the bucket using the bucket, access and region options
          if (opts.dryRun) return callback();
          S3.createBucket({
            Bucket: opts.bucket,
            ACL: opts.access,
            CreateBucketConfiguration: { LocationConstraint: opts.region }
          }, function(err, data){
            if(err) return callback(err);
            grunt.log.writeln('New bucket\'s location is: ' + data.Location);
            // Disable caching if bucket is newly created
            opts.cache = false;
            callback();
          });
        }
      });
    }

    function enableWebHosting(callback) {
      S3.getBucketWebsite({ Bucket:opts.bucket }, function(err){
        if (err && err.name === 'NoSuchWebsiteConfiguration'){
          //opts.enableWeb can be the params for WebsiteRedirectLocation.
          //Otherwise, just set the index.html as default suffix
          grunt.log.writeln('Enabling website configuration on ' + opts.bucket + '...');
          var webOptions = _.isObject(opts.enableWeb) ? opts.enableWeb : { IndexDocument: { Suffix : 'index.html' }};
          if (opts.dryRun) return callback();
          S3.putBucketWebsite({
            Bucket: opts.bucket,
            WebsiteConfiguration: webOptions
          }, callback);
        }else{
          callback(err);
        }
      });
    }

    function getFileList(callback) {
      //calculate prefix
      var prefix = null, pindex = Infinity;
      files.forEach(function(file) {
        if(prefix === null) {
          prefix = file.dest;
          return;
        }
        var i = 0;
        while(i < prefix.length &&
              i < file.dest.length &&
              file.dest.charAt(i) === prefix.charAt(i)) i++;
        pindex = Math.min(i, pindex);
      });
      prefix = prefix.substr(0, pindex);

      //get prefix's earliest refresh time
      var refreshedAt = 0;
      for(var p in cache.prefixes)
        if(prefix.indexOf(p) === 0)
          refreshedAt = Math.max(refreshedAt, cache.prefixes[p]);

      //already have list
      if(cache.files &&
         refreshedAt &&
         opts.cacheTTL &&
         opts.cacheTTL > (Date.now() - refreshedAt)) {
        grunt.verbose.writeln("Using cached object list prefixed with '" + prefix + "'");
        return callback();
      }

      //fetch all objects, beginning with key ''
      fetchObjects('');

      function fetchObjects(marker) {
        var msg = "Retrieving list of existing objects";
        msg += prefix ? " prefixed with '" + prefix + "'" : "";
        msg += marker ? (" after '" + marker + "'") : "";
        msg += "...";
        grunt.log.writeln(msg);

        S3.listObjects({
          Bucket: opts.bucket,
          Marker: marker,
          Prefix: prefix
        }, function(err, objs) {
          if(err) return callback(err);

          //store results
          objs.Contents.forEach(function(obj) {
            cache.files[obj.Key] = JSON.parse(obj.ETag);
          });
          cache.prefixes[prefix] = Date.now();
          stats.refreshed = true;

          if(objs.IsTruncated)
            fetchObjects(objs.Contents.pop().Key);
          else
            callback();
        });
      }
    }

    function copyAllFiles(callback) {
      //asynchrously loop through all files
      async.eachLimit(files, opts.concurrent, getFile, callback);
    }

    function getFile(file, callback) {
      //extract src and dest
      var src = file.src,
          contents = fs.readFileSync(src),
          dest = file.dest;

      if(opts.gzip) {
        zlib.gzip(contents, function(err, compressed) {
          copyFile(src, compressed, dest, callback);
        });
      } else {
        copyFile(contents, contents, dest, callback);
      }
    }

    function copyFile(src, contents, dest, callback) {

      //skip existing files
      var etag = cache.files[dest];
      if(opts.cache &&
         !stats.newOptions &&
         etag && etag === hash(contents, 'md5')) {
        grunt.log.ok(DRYRUN + "No change '" + dest + "'");
        callback();
        return;
      }

      if(!opts.overwrite && etag) {
        grunt.log.ok(DRYRUN + "File already exists '" + dest + "'");
        callback();
        return;
      }

      //fake successful upload
      if(opts.dryRun)
        return putComplete();

      //extend the base object
      var object = Object.create(baseObject);
      object.Key = dest;
      object.Body = contents;
      if(!object.ContentType)
        object.ContentType = mime.lookup(dest);

      // Set a default charset
      if (opts.charset) object.ContentType += '; charset=' + opts.charset;

      //upload!
      S3.putObject(object, putComplete);

      function putComplete(err, results) {
        if(err) {
          return callback("Put '" + dest + "' failed...\n" + err + "\n ");
        }
        grunt.log.ok(DRYRUN + "Put '" + dest + "'");
        if(!opts.dryRun)
          stats.puts++;
        if(results)
          cache.files[dest] = JSON.parse(results.ETag);
        callback();
      }

    }

    function taskComplete(err) {
      if(err) {
        grunt.fail.warn(err);
        return done(false);
      }
      
      //all done
      grunt.log.ok("Put " + stats.puts + " files");
      if(opts.cache && (stats.puts || stats.dels || stats.refreshed || stats.newOptions))
        CacheMgr.put(cache);
      done(err);
    }
  });
Example #17
0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/


var aws = require('aws-sdk');
var logger = require('_pr/logger')(module);

if (process.env.http_proxy) {
    aws.config.update({
        httpOptions: {
            proxy: process.env.http_proxy
        }
    });
}
var AWSCloudFormation = function(awsSettings) {

    var that = this;
    var params = new Object();

    if (typeof awsSettings.region !== undefined) {
        params.region = awsSettings.region;
    }

    if (typeof awsSettings.isDefault !== undefined && awsSettings.isDefault == true) {
        params.credentials = new aws.EC2MetadataCredentials({httpOptions: {timeout: 5000}});
    } else if (typeof awsSettings.access_key !== undefined && typeof awsSettings.secret_key !== undefined) {
Example #18
0
var read = require('fs').readFileSync;
var AWS = require('aws-sdk');
var coAWS = require('..');
var co = require('co');

// make tests that other people
// can actually run :)

var conf = require(process.env.HOME + '/.ec2/segment.json');

AWS.config.update({
  accessKeyId: conf.key,
  secretAccessKey: conf.secret,
  sslEnabled: true,
  region: 'us-west-2'
});

var ec2 = coAWS(new AWS.ec2()); // could also pass in, etc.: new AWS.S3()

describe('wrap', function(){
  it('should be wrapped', function(done){
    co(function *(){
      var res = yield ec2.describeInstances();
      res.should.have.property('Reservations');
    })(done);
  })
})
Example #19
0
"use strict";
const exec = require('child_process').exec;
const fs = require('fs.extra');
const AWS = require('aws-sdk');
const S3Manager = require('./../lib/S3Manager');
const dataSeed = require('./dataSeed');

const configure = {
    "projectId": "awscloudlab",
    "labRegion": "ap-northeast-1",
    "userListS3Bucket": "awscloudlab-userlist",
    "sourceBucket": "cloudformation2.cloudlabhk.com"
};

AWS.config.update({region: configure.labRegion});

let awscloudlabschedulerJar = "awscloudlabscheduler-1.0.jar";
let awscloudlabschedulerZip = "awscloudlab_latest.zip";
let awscloudlabCloudFormation = "AWSCloudLab.yaml";
let awscloudlabschedulerJarFilePath = __dirname + '/../dist/' + awscloudlabschedulerJar;
let awscloudlabschedulerZipFilePath = __dirname + '/../dist/' + awscloudlabschedulerZip;
let awscloudlabCloudFormationFilePath = __dirname + '/../dist/' + awscloudlabCloudFormation;

let runCommand = (cmd, workingDir) => new Promise((resolve, reject) => {
    exec(cmd, {cwd: workingDir}, (error, stdout, stderr) => {
        if (error) {
            console.log(`stderr: ${stderr}`);
            console.log(`stderr: ${error}`);
            reject(`exec error: ${error}`);
            return;
        }
/*
   Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.

   This file is licensed under the Apache License, Version 2.0 (the "License").
   You may not use this file except in compliance with the License. A copy of
   the License is located at

    http://aws.amazon.com/apache2.0/

   This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied. See the License for the
   specific language governing permissions and limitations under the License.
*/

// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'REGION'});

// Create CloudWatch service object
var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'});

cw.disableAlarmActions({AlarmNames: ['Web_Server_CPU_Utilization']}, function(err, data) {
  if (err) {
    console.log("Error", err);
  } else {
    console.log("Success", data);
  }
});
Example #21
0
var AWS = require('aws-sdk')
  , fs = require('fs')
  , sshclient = require('sshclient')
  , async = require('async')

AWS.config.loadFromPath('./config.json');

var ec2 = new AWS.EC2({ region: 'ap-northeast-1' })
  , autoscaling = new AWS.AutoScaling({ region: 'ap-northeast-1' });

var privateKey = fs.readFileSync('../../awskeypair.pem');

function getInstanceIds(callback) {
  autoscaling.describeAutoScalingGroups({
    AutoScalingGroupNames: ['ExampleAutoScalingGroup'],
  }, function (err, data) {
    instanceIds = [];
    if (!err) {
      data.AutoScalingGroups[0].Instances.forEach(function (e) {
        instanceIds.push(e.InstanceId);
      });
    }
    callback(instanceIds);
  });
}

function getInstanceIpAddress(instanceId, callback) {
  ec2.describeInstances({
    InstanceIds: [ instanceId ]
  }, function (err, data) {
    if (err)
Example #22
0
var AWS = require('aws-sdk');
var config = require("./../conf/config.js");

AWS.config.update({
    accessKeyId: config.awsConfig.accessKeyId,
    secretAccessKey: config.awsConfig.secretAccessKey,
    region: config.awsConfig.region
});

var db = new AWS.DynamoDB();

exports.putItem = function(tableName,item,cb) {
    console.log(item);
     db.putItem({
        "TableName": tableName,
        "Item": item
     }, function(err, data) {
       if (err) {
         cb(err,data);
       } else {
         cb(null,data);
       }
     });
 };
  
//function to delete data from the dynamodb table
exports.deleteItem = function(tableName,itemhashkey,cb) {
    console.log(itemhashkey);
     db.deleteItem({
        "TableName": tableName,
        "Key": itemhashkey
import aws from 'aws-sdk'

import config from '../config'

aws.config.update({
  region: config.aws.region,
})

const s3 = new aws.S3({
  httpOptions: {
    timeout: 20 * 60 * 1000,
  },
})

export {
  aws,
  s3,
}

export default aws
}

///
/// Opts.
///

var argv = require('minimist')(process.argv.slice(2));

// AWS credentials from CLI.
var credential_file = argv['f'] || argv['file'];
if( ! credential_file ){
    _die('Option (f|file) is required.');
}else{
    //_ll('Will use credentials: ' + credential_file);
}
AWS.config.loadFromPath(credential_file);

// Bucket/prefix to use.
var bucket = null;
var prefix = null;
var bucket_raw = argv['b'] || argv['bucket'];
if( ! bucket_raw ){
    _die('Option (b|bucket) is required.');
}else{
    var parts = bucket_raw.split('/');
    if( ! parts || parts.length !== 2 ){
	_die('Not a good bucket descriptor: ' + bucket_raw);
    }else{
	bucket = parts[0];
	prefix = parts[1];
    }
Example #25
0
(function () {
	/*
	 * Define Configuration Here.
	 * To Connect with Local DynamoDB, We are providing dummy entries
	 * for required fields(accessKey, Secret and Region).
	 * To Connect with AWS DynamoDB Service place actual accessKey, Secret and Region.
	 * */
	var dynamoDBConfiguration = {
		"accessKeyId": "DummyKeyForLocalDynamoDB",
		"secretAccessKey": "DummySecretAccessKeyForLocalDynamoDB",
		"region": "eu-west-1"
	};

	// requiring aws-sdk, async
	var AWS = require('aws-sdk');
	var async = require('async');

	// For Local DynamoDB define endpoint will be "http://localhost:8000"
	var databaseConfig = {"endpoint": new AWS.Endpoint("http://localhost:8000")};

	// provide your configurations
	AWS.config.update(dynamoDBConfiguration);
	// initialize DynamoDB Object.
	var dynamoDB = new AWS.DynamoDB(databaseConfig);

	var tasks = [];
	var tableName = "OrderLog";
	// Listing tables
	tasks.push(function (callback) {
		dynamoDB.listTables(function (error, data) {
			if (error) {
				console.log("Error: ", error, error.stack);
				callback(error);
			} else {
				console.log("List Of Tables", data.TableNames);
				callback(null);
			}
		});
	});
	/*
	 * Deleting Table
	 * When running first time remove this task as Table will not be present
	 * And it might be throwing an Error.
	 * */
	/*tasks.push(function (callback) {
		dynamoDB.deleteTable({TableName: tableName}, function (error) {
			if (error) {
				console.log("Error: ", error, error.stack);
				callback(error);
			} else {
				console.log("Table ", tableName, " Dropped!");
				callback(null);
			}
		});
	});*/
	// Creating Table
	tasks.push(function (callback) {
		/*
		 * Describe table here
		 * In DynamoDB we can define one primary key and one secondary key, As we know,
		 * DynamoDB is key-value pair base database, so we must have to define primary key.
		 * */
		var table = {
			/*
			 * Defining Primary Key name and type here
			 * Here primary key name is order_id, and type is N(Number)
			 * for other types checkout on (http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html)
			 * */
			AttributeDefinitions: [
				{
					AttributeName: 'order_id',
					AttributeType: 'N'
				}
				// Define Secondary key here.
			],
			/*
			 * Number of attributes must same in key schema, the difference is only here,
			 * we define name with key-type. Name is same as AttributeDefinitions order_id,
			 * and KeyType is HASH
			 * */
			KeySchema: [ // Defining Key Type Here.
				{
					AttributeName: 'order_id',
					KeyType: 'HASH'
				}
				// Define Secondary Key Type Here.
			],
			// Define read per second and write per second here.
			ProvisionedThroughput: {
				ReadCapacityUnits: 1,
				WriteCapacityUnits: 5
			},
			TableName: tableName // table Name
		};
		dynamoDB.createTable(table, function (error, data) {
			if (error) {
				console.log("Error: ", error, error.stack);
				callback(error);
			} else {
				console.log("Table ", tableName, " Created!");
				callback(null);
			}
		});
	});
	// Insert/Update a row
	tasks.push(function (callback) {
		var params = {
			Item: {
				order_id: {
					N: '1234'
				},
				order_body: {
					S: "{a:34, b:34}"
				}
			},
			TableName: tableName
		};
		dynamoDB.putItem(params, function (error, data) {
			if (error) {
				console.log("Error: ", error, error.stack);
				callback(error);
			} else {
				console.log("Row ", JSON.stringify(params), " Inserted!");
				callback(null);
			}
		});
	});
	async.series(tasks, function (error, result) {
		console.log("Result: ", arguments);
	});
})();
Example #26
0
nconf
  .argv()
  .env()
  .file({ file: __dirname + '/config.json' });

var app = express();

var baseUrl = 'https://habitrpg.com';

var db = monk(nconf.get('MONGODB_URL'));
db.options.multi = true;

var AWS = require('aws-sdk');

AWS.config.update({
  accessKeyId: nconf.get('AWS_ACCESS_KEY'),
  secretAccessKey: nconf.get('AWS_SECRET_KEY')
});

var kueRedisOpts = {
  port: nconf.get('REDIS_PORT'),
  host: nconf.get('REDIS_HOST')
};

if(nconf.get('NODE_ENV') === 'production'){
  var redisURL = url.parse(process.env.REDIS_URL);
  kueRedisOpts.auth = redisURL.auth.split(":")[1];
  kueRedisOpts.host = redisURL.hostname;
  kueRedisOpts.port = redisURL.port;
}

var queue = kue.createQueue({
var AWS = require('aws-sdk');

AWS.config.update({
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: process.env.AWS_DEFAULT_REGION
});

var ec2 = new AWS.EC2();
var metadata = new AWS.MetadataService();

var volumeId = process.env.VOLUME_ID;
var instanceId = process.env.INSTANCE_ID || null;  // Read this from the metadata service if not passed in
var device = process.env.DEVICE;

function _getInstanceId(cb) {
  metadata.request('/latest/meta-data/instance-id', function(err, data) {
    if (err) { return cb(err); }
    console.log('Running on instance ' + data);
    cb(null, data);
  });
}

function _detachVolume(cb) {
  console.log('Checking volume ' + volumeId + ' ...');
  ec2.describeVolumes({VolumeIds: [volumeId]}, function(err, data) {
    if (err) { return cb(err); }
    var volume = data.Volumes[0];
    if (volume.Attachments && volume.Attachments.length > 0) {
      console.log('Volume ' + volumeId + ' currently attached to instance ' + volume.Attachments[0].InstanceId);
      console.log('Detaching volume ' + volumeId + ' ...');
var Busboy = require('busboy');
var AWS    = require('aws-sdk');
var config = require('../config.js')
AWS.config.update(config.aws);
var Promise = require('bluebird');
var gm      = require('gm');


var FilePipe = function(params) {
  this.$s3 = Promise.promisifyAll(new AWS.S3());
  this.Bucket = params.bucketName || configs.awsBucket.Bucket;
  if (params.sourceStream) { this.sourceStream = sourceStream; }
  this.transforms = [];
  this._finalized = false;
};

FilePipe.prototype.initialize = function() {

};

FilePipe.prototype.pipeTo = function(outputStream) {

  return this;
};

//takes a transform function and applies it to the stream to create a new stream
FilePipe.prototype.addTransform = function(tfn) {
  this.transforms.push(tfn);
  return this;
};
Example #29
0
var AWS = require("aws-sdk");

AWS.config.update({
  region: "us-west-2",
  endpoint: "http://localhost:8000"
});

var docClient = new AWS.DynamoDB.DocumentClient()

var table = "Movies";

var year = 2015;
var title = "The Big New Movie";

// Conditional update (will fail)

var params = {
    TableName:table,
    Key:{
        "year": year,
        "title": title
    },
    UpdateExpression: "remove info.actors[0]",
    ConditionExpression: "size(info.actors) >= :num",
    ExpressionAttributeValues:{
        ":num": 3
    },
    ReturnValues:"UPDATED_NEW"
};

console.log("Attempting a conditional update...");
Example #30
0
const Consumer = require('sqs-consumer');
const request = require('request');
const AWS = require('aws-sdk');
const async = require('async');
const path = require('path');
const settings = require(path.resolve(__dirname, 'settings.json'));

var prevId = '';
var clientUrl = '';
var serverUrl = '';

try {
	AWS.config.loadFromPath(path.resolve(__dirname, 'settings.json'));

	var sqsClient = new AWS.SQS();

	sqsClient.createQueue({QueueName: "SQS-Proxy-Client"}, function(err, data) {
   		if (err) console.log(err, err.stack); // an error occurred
   		else {
			clientUrl= data.QueueUrl;           // successful response

			var sqsServer = new AWS.SQS();

			sqsServer.createQueue({QueueName: "SQS-Proxy-Server"}, function(err, data) {
   				if (err) console.log(err, err.stack); // an error occurred
   				else {
					serverUrl= data.QueueUrl;           // successful response

					var app = Consumer.create({
  						region:   settings.region,
  						queueUrl: clientUrl,