From 38c983507c5a61a9340642180ab118ee6f1f199a Mon Sep 17 00:00:00 2001 From: Dominick Martelly Date: Thu, 31 Aug 2023 14:30:33 -0400 Subject: [PATCH 1/4] send message to sqs queue by url --- packages/aws/package.json | 2 +- packages/aws/stepDefinitions/sqs.js | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/aws/package.json b/packages/aws/package.json index 4ce10c3..d41bb53 100644 --- a/packages/aws/package.json +++ b/packages/aws/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "2.0.11", + "version": "2.1.2", "description": "AWS steps for MAF. This contains S3, DynamoDB, SQS, ECS, Cloudwatch, and Lambda stepDefinitions", "main": "index.js", "scripts": { diff --git a/packages/aws/stepDefinitions/sqs.js b/packages/aws/stepDefinitions/sqs.js index 3ad8300..0631ae9 100644 --- a/packages/aws/stepDefinitions/sqs.js +++ b/packages/aws/stepDefinitions/sqs.js @@ -23,14 +23,15 @@ async function getURLfromQueueName (queueName) { } /** - * Sends a message to a queue + * Sends a message to a queue using only the queue name * @param {JSON|String} message The message to send - * @param {String} QueueUrl The name of the queue to send the message to + * @param {String} QueueName The name of the queue to send the message to * @returns {JSON} SendMessageCommandOutput (https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sqs/interfaces/sendmessagecommandoutput.html) */ -async function sendMessageToQueue (message, QueueUrl) { - if (!/^https?:\/\//.test(QueueUrl)) { - QueueUrl = await getURLfromQueueName(QueueUrl) +async function sendMessageToQueue (message, QueueName) { + let QueueUrl + if (!/^https?:\/\//.test(QueueName)) { + QueueUrl = await getURLfromQueueName(QueueName) } const queryParameters = { MessageBody: message, QueueUrl } return await sqsClient.send(new SendMessageCommand(queryParameters)) @@ -108,13 +109,19 @@ MAFWhen('queue {string} is purged', async function (QueueUrl) { MAFWhen('{jsonObject} is sent to queue {string}', async function (message, queue) { message = performJSONObjectTransform.call(this, message) queue = filltemplate(queue, this.results) - return await sendMessageToQueue(message, queue) + return sendMessageToQueue(message, queue) }) MAFWhen('{string} message is sent to queue {string}', async function (message, queue) { message = filltemplate(message, this.results) queue = filltemplate(queue, this.results) - return await sendMessageToQueue(message, queue) + return sendMessageToQueue(message, queue) +}) + +MAFWhen('{string} message is sent to queue url {string}', async function (message, QueueUrl) { + message = filltemplate(message, this.results) + QueueUrl = filltemplate(QueueUrl, this.results) + return await sqsClient.send(new SendMessageCommand({ MessageBody: message, QueueUrl })) }) MAFWhen('the next message is received from queue {string}', async function (queueURL) { From 82ce5643a2b702e111e9ca3adc205c6572f2132e Mon Sep 17 00:00:00 2001 From: Dominick Martelly Date: Thu, 31 Aug 2023 14:50:15 -0400 Subject: [PATCH 2/4] queue for jsonObject --- packages/aws/package.json | 2 +- packages/aws/stepDefinitions/sqs.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/aws/package.json b/packages/aws/package.json index d41bb53..03c0d79 100644 --- a/packages/aws/package.json +++ b/packages/aws/package.json @@ -38,5 +38,5 @@ "multiple-cucumber-html-reporter": "^3.4.0", "nyc": "^15.1.0" }, - "gitHead": "9bf55a2c86fa17707fabfb4320c3d722e270f9e6" + "gitHead": "9c565ac48ddb32311b115a463c45625de3ff29e4" } diff --git a/packages/aws/stepDefinitions/sqs.js b/packages/aws/stepDefinitions/sqs.js index 0631ae9..b805c8f 100644 --- a/packages/aws/stepDefinitions/sqs.js +++ b/packages/aws/stepDefinitions/sqs.js @@ -112,6 +112,12 @@ MAFWhen('{jsonObject} is sent to queue {string}', async function (message, queue return sendMessageToQueue(message, queue) }) +MAFWhen('{jsonObject} is sent to queue url {string}', async function (message, QueueUrl) { + message = performJSONObjectTransform.call(this, message) + QueueUrl = filltemplate(QueueUrl, this.results) + return await sqsClient.send(new SendMessageCommand({ MessageBody: message, QueueUrl })) +}) + MAFWhen('{string} message is sent to queue {string}', async function (message, queue) { message = filltemplate(message, this.results) queue = filltemplate(queue, this.results) From 01ac0f7b2e8497e1302c60813823a6a6a1a0bf6a Mon Sep 17 00:00:00 2001 From: Dominick Martelly Date: Tue, 24 Oct 2023 13:34:11 -0400 Subject: [PATCH 3/4] fix up Queue URL --- packages/aws/README.md | 6 +++++- packages/aws/package.json | 2 +- packages/aws/stepDefinitions/sqs.js | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/aws/README.md b/packages/aws/README.md index 3e1701c..0284b6b 100644 --- a/packages/aws/README.md +++ b/packages/aws/README.md @@ -434,7 +434,11 @@ If a queue name is used, a regex search will be done to find the queue. ### `When {jsonObject} is sent to queue {string}` -Sends a new message to the SQS queue provided. `lastRun` will contain the message id and message +Sends a new message to the SQS queue name provided. The first queue that matches the provided name will be used. `lastRun` will contain the message id and message + +### `When {jsonObject} is sent to queue url {string}` + +Sends a new message to the SQS queue URL provided. `lastRun` will contain the message id and message ### `When the next message is received from queue {string}` diff --git a/packages/aws/package.json b/packages/aws/package.json index 31c6bc5..ff093f5 100644 --- a/packages/aws/package.json +++ b/packages/aws/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "2.2.1", + "version": "2.2.3", "description": "AWS steps for MAF. This contains S3, DynamoDB, SQS, ECS, Cloudwatch, and Lambda stepDefinitions", "main": "index.js", "scripts": { diff --git a/packages/aws/stepDefinitions/sqs.js b/packages/aws/stepDefinitions/sqs.js index 1212bbd..b905340 100644 --- a/packages/aws/stepDefinitions/sqs.js +++ b/packages/aws/stepDefinitions/sqs.js @@ -32,6 +32,8 @@ async function sendMessageToQueue (message, QueueName) { let QueueUrl if (!/^https?:\/\//.test(QueueName)) { QueueUrl = await getURLfromQueueName(QueueName) + } else { + QueueUrl = QueueName } const queryParameters = { MessageBody: message, QueueUrl } return await sqsClient.send(new SendMessageCommand(queryParameters)) From 61cfb8167b1ae2ba4ef2ed6ea449015db40a1e7d Mon Sep 17 00:00:00 2001 From: Dominick Martelly Date: Tue, 24 Oct 2023 13:38:09 -0400 Subject: [PATCH 4/4] Fix version number --- packages/aws/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws/package.json b/packages/aws/package.json index ff093f5..31c6bc5 100644 --- a/packages/aws/package.json +++ b/packages/aws/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "2.2.3", + "version": "2.2.1", "description": "AWS steps for MAF. This contains S3, DynamoDB, SQS, ECS, Cloudwatch, and Lambda stepDefinitions", "main": "index.js", "scripts": {