Sunday, 31 December 2017

AWS CloudWatch (Events)

Overview
  • AWS Resources publish information about state changes as CloudWatch Events
  • Target can execute action upon event
  • Rule can route event to Target
  • Use cases
    • Invoke Lambda to modify DNS when EC2 instance is launched
    • Direct CloudTrail records to Kinesis
    • Run SSM command on when instance is launced
    • Log AWS API Calls
  • Near real-time
  • At least-one trigger


Event
  • Triggered by:
    • AWS resource changes state, e.g
      • EC2 instance pending->running
      • ASG launches or terminates an instance
      • EBS created a snapshot
      • Code Deploy instance state change
      • Sign-in to AWS Management Console
      • [many other AWS Services]
    • AWS CloudTrail
      • Can be used as intermediary
      • Read/Write calls supported by CloudTrail can be relayed as Events
    • Customer code publishes event (PutEvents)
    • Scheduled (self-triggered)
      • Cron expressions
      • Rate expressions
  • Uses JSON format
  • Can contain custom payload (useful for Lambda)

Event Bus
  • Each AWS account has default bus
  • Allows sending events to receiver AWS account
    • On receiver account specify permissions
    • Create a rule 
    • Attach foreign Event Bus as a target

Rule
  • matches incoming events and route to targets
  • matching is unordered

Target
  • Receives event as JSON
    • AWS Systems Manager (Run Command)
    • EC2 API calls
    • ECS tasks
    • Lambda
    • Kinesis Streams 
    • SNS
    • [other AWS Services]
    • Event Bus in another account

References

No comments:

Post a Comment