in serverless_artillery/processor.js [53:98]
function setRequest(requestParams, context, _, next) {
let endpoint = '';
if (requestParams.url.includes('unoptimizedEndpointName')){
endpoint = unoptimized_endpoint;
} else if (requestParams.url.includes('optimizedEndpointName')) {
endpoint = optimized_endpoint;
}
let body = '';
for (let i = 0; i < context.vars.numRowsInRequest; i++) {
let row = '2,0.675,0.55,0.175,1.689,0.694,0.371,0.474\n';
body += row;
};
body = body.slice(0, body.length-2);
const canonicalUri = '/endpoints/' + endpoint + '/invocations';
const amzDate = strftime('%Y%m%dT%H%M%SZ', new Date(new Date().toUTCString()));
const dateStamp = strftime('%Y%m%d', new Date(new Date().toUTCString()));
const canonicalHeaders = 'content-type:' + contentType + '\n' + 'host:' + host + '\n' + 'x-amz-date:' + amzDate + '\n' + 'x-amz-security-token:' + sessionToken + '\n';
const payloadHash = crypto.createHash('sha256').update(utf.encode(body)).digest('hex');
const canonicalRequest = method + '\n' + canonicalUri + '\n' + canonicalQuerystring + '\n' + canonicalHeaders + '\n' + signedHeaders + '\n' + payloadHash;
const credentialScope = dateStamp + '/' + region + '/' + service + '/' + 'aws4_request';
const stringToSign = algorithm + '\n' + amzDate + '\n' + credentialScope + '\n' + crypto.createHash('sha256').update(utf.encode(canonicalRequest)).digest('hex');
const signingKey = getSignatureKey(secretKey, dateStamp, region, service);
const signature = crypto.createHmac('sha256', signingKey).update(utf.encode(stringToSign)).digest('hex');
const authorizationHeader = algorithm + ' ' + 'Credential=' + accessKey + '/' + credentialScope + ', ' + 'SignedHeaders=' + signedHeaders + ', ' + 'Signature=' + signature;
const headers = {
'Content-Type': contentType,
'X-Amz-Date': amzDate,
'Authorization': authorizationHeader,
'X-Amz-Security-Token': sessionToken
};
requestParams.headers = headers;
requestParams.body = body;
return next();
};