Is there a way to mimic a CloudWatch SNS notification when creating an alert so that it will be picked up by the CloudWatch API integration instead of the Default API?
I've tried posting SNSEvent JSON payloads and CloudWatch JSON payloads to both my Alerts API with Geniekey and my alerts https endpoint.
The server returns error 422 Unprocessable Entity.
Creating custom alerts otherwise works fine using the parameters listed in the Alerts API
{
"Type": "Notification",
"MessageId": "836fe1ec-79e0-56b8-827f-b66569e37e11",
"TopicArn": "arn:aws:sns:us-east-1:498849832712:update-cherwell-cmdb",
"Message": {
"AlarmName":"Saffron-Octopus-RDS",
"AlarmDescription":null,
"AWSAccountId":"498849832712",
"NewStateValue":"ALARM",
"NewStateReason":"Threshold Crossed: 1 datapoint [2.1533759377604764 (20/07/20 21:07:00)] was greater than or equal to the threshold (0.0175).",
"StateChangeTime":"2020-07-20T21:12:01.544+0000",
"Region":"US East (N. Virginia)",
"AlarmArn":"arn:aws:cloudwatch:us-east-1:498849832712:alarm:Saffron-Octopus-RDS",
"OldStateValue":"INSUFFICIENT_DATA",
"Trigger":{
"MetricName":"CPUUtilization",
"Namespace":"AWS/RDS",
"StatisticType":"Statistic",
"Statistic":"AVERAGE",
"Unit":null,
"Dimensions":[{
"value":"sm16lm1jrrjf0rk",
"name":"DBInstanceIdentifier"
}],
"Period":300,
"EvaluationPeriods":1,
"ComparisonOperator":"GreaterThanOrEqualToThreshold",
"Threshold":0.0175,
"TreatMissingData":"",
"EvaluateLowSampleCountPercentile":""
}
},
"Timestamp": "2020-07-15T14:08:03.824Z",
"SignatureVersion": "1",
"Signature": "JNdxahPfT0tVsX8+ZVPeA23M09UcCbIQ8uar5AZ4VqscGhzqpMcy4v00mluwr3eyJuFsogxhv1RprFIHU0ZH4bNRWxDpzdVnFIGVSnSBZDVi075ynf+oxagTLhSs7aa9Aar38RcQicaYBc6kHiCg5FHIwwU1OXeehVjHavFKC1ymSegaxtD2pUG4jST30gC2P55I+qyFItPOj+Ih8ZqRBXc3H989mwDKU0Qa54/lQ0cFMC8YwZcQzqwSoZQwIvsrCzLjNR7l2IIEq4pk9d2thq9C/tySFNlXd4/HP/Vd6I9wuP08c0nspmmWxQY1X7CQOvwKway7V9WmKVpku3avxQ==",
}
SNSEvent JSON Example:
{ "Records": [ { "EventVersion": "1.0", "EventSubscriptionArn": "arn:aws:sns:us-east-2:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486", "EventSource": "aws:sns", "Sns": { "SignatureVersion": "1", "Timestamp": "2019-01-02T12:45:07.000Z", "Signature": "tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...65r==", "SigningCertUrl": "https://sns.us-east-2.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem", "MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", "Message": "Hello from SNS!", "MessageAttributes": { "Test": { "Type": "String", "Value": "TestString" }, "TestBinary": { "Type": "Binary", "Value": "TestBinary" } }, "Type": "Notification", "UnsubscribeUrl": "https://sns.us-east-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-2:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486", "TopicArn":"arn:aws:sns:us-east-2:123456789012:sns-lambda", "Subject": "TestInvoke" } } ] }