YES!
After some digging, I was able to make it work. It's a little trickier than just picking a theme or entering an alarm, but it works great!
The key to the solution was to use AWS lambda functions!
The data stream is as follows:
> Alarm triggered
> -> Push notification to SNS
> -> SNS posts to lambda
> -> lambda reposts to SNS on us-east-1
> -> subscriber receives message
:
> CloudWatch Alarm (us-west-2)
> -> SNS (us-west-2)
> -> Lambda (us-west-2)
> -> SNS (us-east-1)
> -> SMS subscriber (us-east-1)
SNS , , . , -, , . , .
console.log('Loading function');
var Aws = require('aws-sdk');
var usEastSns = new Aws.SNS({
accessKeyId: "ENTER YOUR ACCESS KEY HERE",
secretAccessKey: "ENTER YOUR SECRET KEY HERE",
region: "us-east-1",
logger: console
});
exports.snsProxy = function(event, context) {
var message = event.Records[0].Sns;
console.log("received message: ", message);
var newMessage = buildNewMessage(message);
console.log("publishing: ", newMessage);
usEastSns.publish(newMessage, function(err, data) {
if (err) {
console.log(err, err.stack);
} else {
console.log(data);
context.succeed(message);
}
})
};
function buildNewMessage(message) {
return {
TargetArn: "ENTER YOUR ARN IN US EAST HERE",
Message: message.Message,
Subject: message.Subject,
MessageAttributes: collectAttr(message.MessageAttributes)
};
}
function collectAttr(attrs) {
var newAttrs = {};
for (var attr in attrs) {
newAttrs[attr] ={
DataType: attrs[attr].Type,
StringValue: attrs[attr].Value
}
}
return newAttrs;
}
, aws-sdk, -. , , .
, , . , , .
, - -1, , .
:
SNS api:
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#publish-property
node.js lambda:
http://docs.aws.amazon.com/lambda/latest/dg/programming-model.html
aws:
http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html