Complete the code to specify the dead letter queue ARN in the AWS SQS queue configuration.
QueueUrl = sqs.create_queue(QueueName='MyQueue', Attributes={'RedrivePolicy': '{"deadLetterTargetArn":"[1]"}'})
The dead letter queue ARN must point to an SQS queue. Here, option A is the correct ARN format for an SQS dead letter queue.
Complete the code to set the maximum receive count before moving messages to the dead letter queue.
RedrivePolicy = '{"maxReceiveCount": [1], "deadLetterTargetArn": "arn:aws:sqs:us-east-1:123456789012:MyDeadLetterQueue"}'
The maxReceiveCount must be a positive integer. Setting it to 5 means after 5 failed receives, the message moves to the dead letter queue.
Fix the error in the RedrivePolicy JSON string to correctly configure the dead letter queue.
RedrivePolicy = '{"maxReceiveCount": 3, "deadLetterTargetArn": [1]'
The ARN value inside the JSON string must be enclosed in double quotes to be valid JSON.
Fill both blanks to create a dead letter queue and attach it to the main queue.
dlq_url = sqs.create_queue(QueueName='DeadLetterQueue') dlq_arn = sqs.get_queue_attributes(QueueUrl=dlq_url, AttributeNames=['[1]'])['Attributes']['[2]']
To get the ARN of the dead letter queue, first get its URL (QueueUrl), then request the 'QueueArn' attribute.
Fill all three blanks to configure the main queue with a dead letter queue and max receive count.
dlq_arn = '[1]' redrive_policy = '{"maxReceiveCount": [2], "deadLetterTargetArn": "[3]"}' main_queue_url = sqs.create_queue(QueueName='MainQueue', Attributes={'RedrivePolicy': redrive_policy})
The dead letter queue ARN is assigned to dlq_arn (option C). The maxReceiveCount is set to 5 (option B). The RedrivePolicy uses the ARN string (option A).