aws / aws-toolkit-azure-devops

AWS Toolkit for Azure DevOps
Other
247 stars 104 forks source link

SQS Create-Queue Double Quotes missing from command? #103

Open JulioIzquierdo opened 6 years ago

JulioIzquierdo commented 6 years ago

While creating a queue and assigning it a dead letter queue, I'm having issue with creating the queue. It's states that the Redrive policy is not a valid JSON map. What I'm noticing in the command is that a double quote is missing right before the deadLetterTargetArn property in the command. Could this be the culprit? I would appreciate some looking into and feedback to see if I'm doing something wrong.

Parameters in VSTS --queue-name $(JobRunner.BatchReport.QueueName) --attributes RedrivePolicy='{\"deadLetterTargetArn\":\"$(APN)\", \"maxReceiveCount\":\"5\"}'

In Debug

[debug]awsArguments=--queue-name Master_Local_JDI_BatchReporting --attributes RedrivePolicy='{\"deadLetterTargetArn\":\"arn:aws:sqs:redacted:Master_Local_JDI_BatchReporting_dlq\", \"maxReceiveCount\":\"5\"}'

Command [command]"C:\Program Files\Amazon\AWSCLI\aws.exe" sqs create-queue --queue-name Master_Local_JDI_BatchReporting --attributes "RedrivePolicy='{\deadLetterTargetArn\":\"redacted:Master_Local_JDI_BatchReporting_dlq\", \"maxReceiveCount\":\"5\"}'"

stevejroberts commented 6 years ago

Apologies for the delay in responding; combination of vacations and team focus elsewhere for the moment :-)

Thanks for reporting the problem, we'll take a look and see if we can repro.

stevejroberts commented 6 years ago

Repro'd - looks like an issue with the parsing code inside the VSTS task lib (the 'line()' method on the task runner class) that we use to construct the command line, since everything looks fine up until that point.

My guess is that we'll need to see if we can construct the command line differently. I'll update when I know more.

JulioIzquierdo commented 6 years ago

Thanks for the feedback. My workaround was to add a Power Shell task to write the policy in JSON format and consuming it in the next AWS CLI task as shown below:

# Write the Redrive Policy to json file
$dLTARN = $Env:ARN
$policy= '{ "RedrivePolicy":"{\"deadLetterTargetArn\":\"$dLTARN\", \"maxReceiveCount\":\"5\"}" }'
$ExecutionContext.InvokeCommand.ExpandString($policy) | Out-File .\RedrivePolicy.json -Encoding ascii

And the next task would be the AWS CLI to create the queue with the following parameters:

--queue-name $(QueueName) --attributes file://RedrivePolicy.json

Make note of the Encoding so that it will not write BOM otherwise it will fail.

Hope this helps anyone in the meantime. :-)

stevejroberts commented 6 years ago

Thanks for the workaround tip :-)