Last active
January 22, 2021 14:27
-
-
Save charlypoly/1e6c30c574218ae27ca3d2e946432f97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = (event, context, callback) => { | |
var AWS = require('aws-sdk'); | |
AWS.config.update({region: 'eu-west-1'}); // configure region | |
const athena = new AWS.Athena(); | |
athena.getNamedQuery({ NamedQueryId: '<your-query-id>' }, function(err, data) { | |
console.log('getNamedQuery', err, data); | |
if (!err) { | |
var params = { | |
QueryString: data.NamedQuery.QueryString, | |
ResultConfiguration: { | |
OutputLocation: 's3://<your-bucket-name>/<folder>', | |
}, | |
QueryExecutionContext: { | |
Database: 'segment' | |
} | |
}; | |
athena.startQueryExecution(params, function(err, data) { | |
console.log('startQueryExecution', err, data); | |
if (err) { | |
callback(err); | |
} else { | |
callback(null, 'query started'); | |
} | |
}); | |
} else { | |
callback(err); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment