Hello all,
AWS and node.js noob here. I am trying to save a code captured from URL parameters to my parameters store in the System Manager service, and later return a hashed value from various strings. My code returns the hash and I don't have any errors in the console, but when I test it with URL/?code=1234&challenge_code=5678, nothing changes in my parameter store. I already have an object named ebayUserCode in there of type string.
exports.handler = async (event) => {
const crypto = require('crypto');
const AWS = require('aws-sdk')
let verificationToken = "FIXME";
let endpoint = "FIXME";
let code = "code";
let challengeCode = "challenge_code";
if (event.queryStringParameters && event.queryStringParameters.code) {
console.log("Received name: " + event.queryStringParameters.code);
code = event.queryStringParameters.code;
var ssm = new AWS.SSM();
var params = {
Name: 'ebayUserCode', /* required */
Value: code, /* required */
Overwrite: true
};
ssm.putParameter(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
}
if (event.queryStringParameters && event.queryStringParameters.challengeCode) {
console.log("Received name: " + event.queryStringParameters.challengeCode);
challengeCode = event.queryStringParameters.challengeCode;
}
const hash = crypto.createHash('sha256');
hash.update(challengeCode);
hash.update(verificationToken);
hash.update(endpoint);
const responseHash = hash.digest('hex');
console.log(new Buffer.from(responseHash).toString());
const response = {
statusCode: 200,
body: responseHash,
};
return response;
};
What am I doing wrong? Any help would be greatly appreciated.
Thanks in advance!
Changed to this:
Also tried this:
Still no change to my parameter in ssm. The actual call was copied verbatim from the API documentation here: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SSM.html#putParameter-property
Sorry about the formatting!