Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ],
// "Resource": [
// "*"
// ]
// }
// ]
// }
'use strict';
console.log('Loading function');
// Init the AWS connection.
const AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
AWS.config.logger = process.stdout; // Debug
if (!process.env.LAMBDA_TASK_ROOT) {
// For unit test, set the credentials.
const config = require('os').platform() === 'win32' ?
require('../../../unabiz-emulator/config.json') :
require('../../../../SIGFOX/unabiz-emulator/config.json');
AWS.config.credentials = {
accessKeyId: config.accessKeyId,
secretAccessKey: config.secretAccessKey,
};
}
// Use AWS command line "aws iot describe-endpoint" to get the endpoint address.
const endpoint = 'A1P01IYM2DOZA0.iot.us-west-2.amazonaws.com';
// Open the AWS IoT connection with the endpoint.
const iotdata = new AWS.IotData({ endpoint });
// Load the SDK for JavaScript
const AWS = require('aws-sdk');
const fs = require('fs');
// Set the region
AWS.config.update({ region: 'us-east-1' });
AWS.config.setPromisesDependency(require('bluebird'));
const appsync = new AWS.AppSync({ apiVersion: '2017-07-25' });
// For creating User Pool: Reference https://serverless-stack.com/chapters/create-a-cognito-user-pool.html
// API key is not recommended for security.
const graphQLAPIName = '...'; // your graphQL API Name
const awsRegion = 'us-east-1'; // AWS Region ex - us-east-1
const userPoolId = '...'; // Your Cognito User Pool Id
const roleName = 'Dynamo-AppSyncServiceRole';
const accountId = '...';
const serviceRole = `arn:aws:iam::${accountId}:role/${roleName}`; // Service IAM Role for appsync to access data sources
const MAX_RETRIES = 20;
let appId;
function wait(timeout) {
overwriteAWSCredentials(credentials) {
AWS.config.credentials = credentials;
// tokenManager will create a new instance of CognitoSyncClient
if (this._token) {
this._token._sts.credentials = credentials;
if (this._token._tokenManager) {
this._token._tokenManager._cognitoSyncClient = null;
}
}
return this;
}
}
// Don't pollute or overwrite production files
var root = require('./root');
var BAD_PARAM = 'Please a path or url to upload';
var shouldGZIP = ['.css', '.js'];
var forGZIP = {ContentEncoding: 'gzip', Vary: 'Accept-Encoding'};
var MAX_EXPIRY = 'public, max-age=31536000';
var AWS = require('aws-sdk');
var CDN_BUCKET = config.cdn.bucket;
var CDN_HOST = config.cdn.host;
// Load in my credentials...
AWS.config.update({
accessKeyId: config.aws.key,
secretAccessKey: config.aws.secret
});
function upload (path, options, callback) {
if (type(options,'function') && !callback) {
callback = options;
options = {};
}
ensure(path, 'string')
.and(options, 'object')
.and(callback, 'function');
path = path.trim();
var aws=require('aws-sdk')
var response = require('cfn-response')
aws.config.region=process.env.AWS_REGION
var sagemaker=new aws.SageMaker()
var lambda=new aws.Lambda()
exports.handler=function(event,context,callback){
console.log(JSON.stringify(event,null,2))
var params=event.ResourceProperties
delete params.ServiceToken
new Promise(function(res,rej){
if(event.RequestType==="Wait"){
sagemaker.describeNotebookInstance({
NotebookInstanceName:params.NotebookInstanceName
}).promise()
.then(function(result){
if(result.NotebookInstanceStatus==="InService"){
response.send(event, context, response.SUCCESS)
res()
function sendTxtMessage(params, callback) {
var AWS = require('aws-sdk');
AWS.config.update({region: AWSregion});
var SNS = new AWS.SNS();
SNS.publish(params, function(err, data){
console.log('sending message to ' + params.PhoneNumber.toString() );
if (err) console.log(err, err.stack);
callback('text message sent');
});
}
require('env2')('./.env')
var AWS = require('aws-sdk')
var crypto = require('crypto')
var path = require('path')
var handleError = require('hapi-error').handleError
AWS.config.region = process.env.AWS_S3_REGION
function upload (file, filename, callback) {
var ext = '.' + path.extname(filename)
var filenameHex = filename.replace(ext, '') +
crypto.randomBytes(8).toString('hex') + ext
var bucket = process.env.AWS_S3_BUCKET
console.log(bucket)
var s3Bucket = new AWS.S3({params: {Bucket: bucket}})
var params = {Bucket: bucket, Key: filenameHex, Body: file}
s3Bucket.upload(params, function (err, data) {
handleError(err, data)
callback(null, data)
})
}
module.exports = {
'use strict';
const AWS = require('aws-sdk');
AWS.config.setPromisesDependency(require('bluebird'));
AWS.config.update({ region: 'us-east-1' });
const fetchPreferences = (chatId) => {
return new Promise((resolve, reject) => {
const dynamodb = new AWS.DynamoDB();
dynamodb.getItem({
TableName: "pollyanna_bot",
Key: {
'chat_id' : { N: chatId.toString() },
},
}, (err, data) => {
if (err) reject(err);
else {
const item = data.Item;
const voice = item ? item.voice_id.S : null;
resolve(voice);
}
export default () => {
AWS.config.update({
region: config.dbRegion,
endpoint: config.dbLocalUrl,
});
};
#!/usr/bin/env node
const AWS = require('aws-sdk'),
readline = require('readline-sync'),
pathPrefix = '/felix/',
{ ssmToObjByPath } = require('ssm-params');
if (!AWS.config.region) {
const region = readline.question('Please specify which region to set these parameters in (us-east-1): ', { defaultInput: 'us-east-1' });
AWS.config.update({ region });
}
const ssm = new AWS.SSM();
const config = [
{
Name: 'aws',
Description: 'AWS-specific settings for locating IAM users and notifying SNS.',
required: true,
parameters: [
{
Name: 'snsTopic',
default: `arn:aws:sns:${AWS.config.region}:[account id]:FelixReports`,
Description: 'The SNS topic to publish Felix reports.',
Type: 'String'
},