{   "Parameters": {
    "SupportSQSName":{
       "Default": "AwsServiceManagementConnectorSupportQueue",
       "Description": "This is the name of the SQS queue which the connector will use to pass AWS Support incidents to the ITSM connector.  This name must match the value in the ITSM tool connector settings. Do Not Change this unless you make corresponding changes in the ITSM application setup.",
       "Type": "String"
    }	   
},
    "Resources":{
        "AWSSupportEventsRule": {
            "Properties": {
               "Description": "Send AWS Support Case events to the AwsServiceManagementConnectorSupportQueue SQS.",
               "EventPattern": {
                  "source": [
                     "aws.support"
                  ]
               },
               "Targets": [
                  { "Arn": {
                      "Fn::Sub": "arn:aws:sqs:us-east-1:${AWS::AccountId}:AwsServiceManagementConnectorSupportQueue"
                    },
                    "Id": "JSM-AWSSupportEventsRule"
                  }
               ]
            },
            "Type": "AWS::Events::Rule"
         },
         "AwsServiceManagementConnectorSupportQueue": {
            "Properties": {
               "QueueName": {"Ref":"SupportSQSName"},
               "Tags": [
                  {
                     "Key": "Name",
                     "Value": {"Ref":"SupportSQSName"}
                  }
               ]
            },
            "Type": "AWS::SQS::Queue"
         },
         "SQSPolicy": {
            "Type": "AWS::SQS::QueuePolicy",
            "Properties": {
               "Queues": [
                  {
                     "Ref": "AwsServiceManagementConnectorSupportQueue"
                  }
               ],
               "PolicyDocument": {
                  "Statement": [
                     {
                        "Action": "SQS:SendMessage",
                        "Effect": "Allow",
                        "Resource": {
                           "Fn::GetAtt": [
                              "AwsServiceManagementConnectorSupportQueue",
                              "Arn"
                           ]
                        },
                        "Principal": {
                           "Service": "events.amazonaws.com"
                        },
                        "Condition": {
                           "ArnEquals": {
                              "aws:SourceArn": {
                                 "Fn::GetAtt": [
                                    "AWSSupportEventsRule",
                                    "Arn"
                                 ]
                              }
                           }
                        }
                     }
                  ]
               }
            }
         }
    }
}