Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async upload(ctx: JovoTaskContextLambda, project: Project): Promise {
ctx.src = ctx.src.replace(/\\/g, '\\\\');
if (process.env.AWS_ACCESS_KEY_ID === undefined || process.env.AWS_SECRET_ACCESS_KEY === undefined) {
// Only set profile when special AWS environment variables are not set
let awsProfile = 'default';
if (ctx.askProfile) {
awsProfile = this.getAWSCredentialsFromAskProfile(ctx.askProfile);
}
if (ctx.awsProfile) {
awsProfile = ctx.awsProfile;
}
AWS.config.credentials = new AWS.SharedIniFileCredentials({ profile: awsProfile });
}
const region = ctx.lambdaArn.match(/([a-z]{2})-([a-z]{4})([a-z]*)-\d{1}/g);
if (!region) {
return Promise.reject(new Error(`No region found in "${ctx.lambdaArn}"!`));
}
AWS.config.region = region[0];
const proxyServer = process.env.http_proxy ||
process.env.HTTP_PROXY ||
process.env.https_proxy ||
process.env.HTTPS_PROXY;
if (proxyServer) {
AWS.config.update({
httpOptions: {
'import-schema': importSchemaCli,
'list-tables': listTablesCli,
'export-all-schema': exportAllSchemaCli,
'export-data': exportDataCli,
'export-all-data': exportAllDataCli,
'export-all': exportAllCli,
'import-data': importDataCli,
'wipe-data': wipeDataCli
};
if (cli.flags.maxRetries !== undefined) AWS.config.maxRetries = cli.flags.maxRetries;
const method = methods[cli.input[0]] || cli.showHelp();
if (cli.flags.profile) {
AWS.config.credentials = new AWS.SharedIniFileCredentials({profile: cli.flags.profile});
}
if (cli.flags.caFile) {
console.log('Using self signed cert', cli.flags.caFile);
const ca = fs.readFileSync(cli.flags.caFile);
AWS.config.update({
httpOptions: { agent: new https.Agent({ ca }) }
});
}
bluebird.resolve(method.call(undefined, cli))
.catch(err => {
console.error(err.stack);
process.exit(1);
});
me.findService = function(input) {
var params = {region:input.region};
if (input.creds) params.credentials = input.creds;
else if (input.profile) {
var credentials = new AWS.SharedIniFileCredentials({profile: input.profile});
AWS.config.credentials = credentials;
}
var sns = new AWS.SNS(params);
return sns;
}
Object.values(deploy).forEach(target => {
Object.assign(target, {
publisher: publish.create({
region: target.region,
params: {
Bucket: target.bucket,
},
credentials: new aws.SharedIniFileCredentials({ profile: 'plyr' }),
}),
});
});
setup: function(_userDataReader, _userDataWriter, cb) {
userDataReader = _userDataReader;
userDataWriter = _userDataWriter;
credentials = new AWS.SharedIniFileCredentials({
profile: config.AWSCredentialsProfile
});
AWS.config.credentials = credentials;
AWS.config.region = config.AWSRegion;
iam = new AWS.IAM();
ec2 = new AWS.EC2();
ssm = new AWS.SSM();
sts = new AWS.STS();
async.parallel([
getStoppedInstances,
getSSMRole,
getSecurityGroup,
getKeyPair,
var BbPromise = require('bluebird');
var AWS = require('aws-sdk');
var credentials = new AWS.SharedIniFileCredentials({
profile: 'default'
});
AWS.config.credentials = credentials;
var Utils = function() {};
Utils.getTableSchema = function(_table_name, _region) {
return new BbPromise(function(resolve) {
AWS.config.update({
region: _region
});
var dynamodb = new AWS.DynamoDB();
var params = {
TableName: _table_name
import { Lambda, SharedIniFileCredentials } from 'aws-sdk'
import { awsToString } from '../parser'
import { IAtoms, IContentAtomElementFields } from '@guardian/capi-ts'
import { BlockElement } from '../../Apps/common/src'
import { IAtom } from '@guardian/capi-ts/dist/com/gu/contentatom/thrift/Atom'
import { attempt, hasFailed } from '../utils/try'
import { oc } from 'ts-optchain'
import { getImageFromURL } from '../image'
import { getPlatformName } from './consts'
const creds = process.env.arn
? {}
: {
credentials: new SharedIniFileCredentials({ profile: 'frontend' }),
}
const lambda = new Lambda({
region: 'eu-west-1',
...creds,
})
export const rationaliseAtoms = (atoms?: IAtoms) => ({
audio: (atoms && atoms.audios) || [],
chart: (atoms && atoms.charts) || [],
commonsdivision: (atoms && atoms.commonsdivisions) || [],
cta: (atoms && atoms.cta) || [],
explainer: (atoms && atoms.explainers) || [],
guide: (atoms && atoms.guides) || [],
interactive: (atoms && atoms.interactives) || [],
media: (atoms && atoms.media) || [],
profile: (atoms && atoms.profiles) || [],
function createCfnClient(region, profile) {
const cfnOptions = {
apiVersion: '2010-05-15'
};
if (profile !== undefined) {
cfnOptions.credentials = new AWS.SharedIniFileCredentials({tokenCodeFn: tokenCodeFn, profile: profile});
}
if (region !== undefined) {
cfnOptions.region = region;
}
return new AWS.CloudFormation(cfnOptions);
}