AWS CloudWatch logs in multiple regions - amazon-web-services

I created a lambda function in us-east-1 and sns topic to send notifications to a slack channel.
Now I also want to use logs from a service in us-west-2 to trigger the notifications but I can't because they are in different regions.
Whats the best way to handle this? I could just copy the Lambda function/sns topic into us-west-2 but that seems redundant....
Thanks

I decided to go with separate lambda functions in each region.
Since Network Manager is only available in US West 2 and the messages being processed will be specific to that region.

Related

AWS Avoiding Duplicates in East and West SNS triggered lambda

We basically want to create an active passive setup without being active passive. So all aws services must be replicated in both regions. But routing can be different. Flow Currently. SNS -> Lambda
We currently have a lambda triggered by an SNS after another process we cant control is completed. Active - Active east wand west. Each region has its own sns trigger triggering it. East does processing and west does processing separately and they each print a file.
Current issue is east & west are both processing and outputting copies of the same file. Any suggestions on how I can resolve this ideally in the aws space? So only one lambda is triggered.
We need to have active active lambdas
Thought of sns -> sqs -> lambda. But havent thought of how to get around the routing for having a copy in each region.
Seems filtering can be done for sqs but can sqs policies talk to each other during this filtering?
Found an image thats a perfect depiction of what we have but what I DONT WANT. In the end I want only File 1 to send.
Diagram

AWS cloudwatch alerting poll API

I can see that in AWS alerting works with SNS where protocols are available as Email, https and SMS...Basically push mechanisms..
Is it possible to make these alerts pull-based? any ideas around how this could be tried?
You would need to create a solution for this, natively when an alert triggers it can be configured to go to either an SNS topic which has 1 or more subscriptions to notify.
Instead you would need to use the describe-alarms function to retrieve a list of alarms, this can be narrowed down to alarming only by using the --state-value parameter such as the example below
aws cloudwatch describe-alarms --state-value ALARM
Does this fit your needs https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudwatch/describe-alarm-history.html ?
Please check aws cloudwatch there are several options for alarms.

AWS - is there a way to receive events asynchronously without the lambda

I have a general AWS question. I have started using AWS sdk, but looks like if I want to receive events asynchronously from AWS(ex: cloudwatch events), lambda functions is the only way. I want to write a simple application that registers a callback to AWS for events, but i couldn't find a way to do that till now, since i don't want to use lambda, i have been polling from my application. Please, let me know if polling is the only option or if there is a better way to resolve it without polling.
From the documentation:
You can configure the following AWS services as targets for CloudWatch Events:
Amazon EC2 instances
AWS Lambda functions
Streams in Amazon Kinesis Streams
Delivery streams in Amazon Kinesis Firehose
Amazon ECS tasks
SSM Run Command
SSM Automation
Step Functions state machines
Pipelines in AWS CodePipeline
Amazon Inspector assessment templates
Amazon SNS topics
Amazon SQS queues
Built-in targets
The default event bus of another AWS account
That's a lot more than just Lambda, so I'm not sure why you state in your question that Lambda is the only option. The options of Amazon EC2 instances and Amazon SNS topics both provide a method for Amazon to "push" the events to your services, instead of requiring your services to poll.
With cloudwatch events, you can set rules and trigger a number of different targets, including SQS queues which you can poll from your EC2 Instances.
Lambda is certainly a popular endpoint, but based on the docs, there are other targets you can send the events to
Already above answers might also be helpful, but one of the possible options to address your problem could be one of this as well.
You can make use of AWS SNS service to subscribe for the events on AWS resources. And the SNS can publish the events to your application end point. Which is nothing but pub/sub model.
Refer this link http://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html
The end-point could be your http or https based application.

Cloudwatch trigger to Aws lambda

I am using cloudwatch to trigger AWS Lambda. Now to create this trigger first of all I have to create rule then I need to add target and then I need to add permission policy to that lambda function. Now the problem is there is a policy length limit(20k) for each lambda function and each cloudwatch trigger increase policy length. So if there are around 60 cloudwatch rules my lambda can still handle all of those events as size is still less than 20k, but after that if rules increase I get http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html "policy length exceed exception error".
I know I can delete the policy by using removePermission method but that is not efficient because if there are around 100 rules present in cloudwatch which are triggering my lambda function then my lambda function can't handle that much amount of policy length.
This is how I solved it.
Cloudwatch Alerts --> SNS --> Lambda
No subscription, no permissions configuration needed. You can create multiple different SNS notifications if you want to isolate different team based on your alerts.
Steps:
Create SNS with a topic
Send Cloudwatch Alerts to SNS
Subscribe Lambda to that SNS Topic
Receive Alerts to Lambda!
Hope it helps.

Can a CloudWatch Event in one region trigger a Lambda in another region of AWS?

Can an AWS CloudWatch event in region us-east-1 trigger a lambda in us-west-2? Or do I have to deploy my lambda in both regions?
An alternative is to have CloudWatch trigger SNS. As per the attached screenshot, SNS topic subscription will allow full ARN declaration, and the dropdown even showed a us-east-1 lambda when I was in US West (Oregon) region.
SNS Screenshot
From the dashboard, it is not possible to trigger cross region Lambda. When you create a CloudWatch event rule, select a Target to invoke, under Lambda function only the lambdas in the current region are shown.
This could be achieved by creating a the Event Rule in the source Region as well as SNS Topic in the same Region as a Target.
Then subscribe a Lambda in the target region to this SNS Topic.
You may relay an event to a Eventbus in the desired region. There you can set an event rule to trigger the desired lambda.