// Load the SDK for JavaScript
var AWS = require('aws-sdk');
//コンフィグの読み込み
var ini = require('./config/config.json');
var REGION = ini.sqs.test.region;
var SQS_QUEUE_URL = ini.sqs.test.url;
var SQS_ACCESS_KEY_ID = ini.sqs.test.accessKeyId;
var SQS_SECRET_ACCESS_KEY = ini.sqs.test.secretAccessKey;
console.log("▼▼▼ get setting information start ▼▼▼");
console.log(SQS_QUEUE_URL);
console.log(SQS_ACCESS_KEY_ID);
console.log(SQS_SECRET_ACCESS_KEY);
console.log("▲▲▲ get setting information end ▲▲▲");
// Set the config
AWS.config.update(
{
accessKeyId: SQS_ACCESS_KEY_ID,
secretAccessKey: SQS_SECRET_ACCESS_KEY,
region: REGION
}
);
// Create an SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var params = {
MessageAttributes: {
"Title": {
DataType: "String",
StringValue: "The Whistler"
},
"Author": {
DataType: "String",
StringValue: "John Grisham"
},
"WeeksOn": {
DataType: "Number",
StringValue: "6"
}
},
MessageBody: "Information about current NY Times fiction bestseller for week of 12/11/2016.",
QueueUrl: SQS_QUEUE_URL,
MessageGroupId: '20180608'
};
sqs.sendMessage(params, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.MessageId);
}
});