According to this article it's possible to set SQS as target for scheduled CloudWatch event:
https://aws.amazon.com/ru/about-aws/whats-new/2016/03/cloudwatch-events-now-supports-amazon-sqs-queue-targets/
I've created a simple Cloud Formation template that aims to trigger CloudWatch event each minute so the new message should appear in SQS, but something is missing as there are no messages in SQS.
The code:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "stack 1",
"Parameters": {
},
"Resources": {
"MyQueue": {
"Type": "AWS::SQS::Queue",
"Properties": {
"QueueName": "MyQueue"
}
},
"MyRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"RoleName": "MyRole",
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"Service": ["events.amazonaws.com", "lambda.amazonaws.com"]
},
"Action": "sts:AssumeRole"
}]
},
"Path": "/",
"Policies": [{
"PolicyName": "CloudWatchPolicy",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}]
}
}]
}
},
"MyRule": {
"Type": "AWS::Events::Rule",
"Properties": {
"Description": "A rule to schedule data update",
"Name": "MyRule",
"ScheduleExpression": "rate(1 minute)",
"State": "ENABLED",
"RoleArn": {
"Fn::GetAtt": ["MyRole",
"Arn"]
},
"Targets": [{
"Arn": {
"Fn::GetAtt": ["MyQueue",
"Arn"]
},
"Id": "MyRule"
}]
}
}
},
"Outputs": {
}
}
What can be wrong there? Should I add a queue listener to make messages appear?
Question #2:
Docs about CloudWatch Event Rule Target declare that Id is a required field:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-target.html
Though AWS::SQS::Queue has no such property at all (only Name is present):
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html#aws-properties-sqs-queues-prop
What should be put to CloudWatch Event Rule Target Id property when SQS is used as a target?
Many thanks in advance.