Skip to content

Instantly share code, notes, and snippets.

@imujjwal96
Last active July 20, 2018 09:13
Embed
What would you like to do?
AWS JavaScript SDK to launch an EMR Cluster with EMRFS Consistent View enabled.
var express = require('express');
var router = express.Router();
var AWS = require('aws-sdk');
AWS.config.update({region: 'ap-south-1'});
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.post('/perform', function (req, res, next) {
var emr = new AWS.EMR();
var params = {
Instances: {
Ec2KeyName: 'training-key',
Ec2SubnetId: 'subnet-xxxxxxxx',
EmrManagedMasterSecurityGroup: 'sg-xxxxxxxxxxxxxxxxx',
EmrManagedSlaveSecurityGroup: 'sg-xxxxxxxxxxxxxxxxx',
HadoopVersion: '2.8.3',
TerminationProtected: false,
InstanceGroups: [{
Name: "Master Instance Group",
InstanceRole: "MASTER",
InstanceCount: 1,
InstanceType: "m4.large",
Market: "ON_DEMAND"
}]
},
Name: 'Testing-cluster',
Applications: [
{
Name: 'Ganglia',
},
{
Name: 'Spark',
},
],
Configurations: [
{
Classification: 'emrfs-site',
Properties: {
'fs.s3.consistent.retryPeriodSeconds': '10',
'fs.s3.consistent.retryCount': '5',
'fs.s3.consistent': 'true',
'fs.s3.consistent.metadata.tableName': 'EmrFSMetadata'
}
},
],
JobFlowRole: 'EMR_EC2_DefaultRole',
LogUri: 's3://aws-logs-xxxxxxxxxxxx-ap-south-1/elasticmapreduce/',
ReleaseLabel: 'emr-5.15.0',
ServiceRole: 'EMR_DefaultRole',
};
emr.runJobFlow(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment