cloudwatch

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 3 Imported by: 1

README

Apex CloudWatch

Providing CloudWatch Events for Apex

Features

Currently only supports the following event details:

  • AutoScaling
  • EC2
  • Console Sign-In
  • Schedule

Unknown events will have empty details

Example

package main

import (
    "log"

	"github.com/apex/go-apex"
	"github.com/apex/go-apex/cloudwatch"
)

func main() {
	cloudwatch.HandleFunc(func(evt *cloudwatch.Event, ctx *apex.Context) error {
        log.Println("Handler called")
        return nil
    }
}

GitHub @sthulb  ·  Twitter @sthulb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handle

func Handle(h Handler)

Handle CloudWatch Events with handler.

func HandleFunc

func HandleFunc(h HandlerFunc)

HandleFunc handles CloudWatch Events with callback function.

Types

type APIDetail

type APIDetail struct {
	EventID      string    `json:"eventID"`
	EventName    string    `json:"eventName"`
	EventSource  string    `json:"eventSource"`
	EventTime    time.Time `json:"eventTime"`
	EventType    string    `json:"eventType"`
	EventVersion string    `json:"eventVersion"`

	AWSRegion           string            `json:"awsRegion"`
	AdditionalEventData map[string]string `json:"additionalEventData,omitempty"`
	RequestParams       interface{}       `json:"requestParameters"`
	ResponseElements    map[string]string `json:"responseElements,omitempty"`
	SourceIPAddress     string            `json:"sourceIPAddress"`
	UserAgent           string            `json:"userAgent"`
	UserIdentity        UserIdentity      `json:"userIdentity,omitempty"`
}

APIDetail of the triggered event This is useful for API or Console events

type AutoScalingGroupDetail

type AutoScalingGroupDetail struct {
	ActivityID           string            `json:"ActivityId"`
	AutoScalingGroupName string            `json:"AutoScalingGroupName"`
	Cause                string            `json:"Cause"`
	Details              map[string]string `json:"Details"`
	EC2InstanceID        string            `json:"EC2InstanceId"`
	RequestID            string            `json:"RequestId"`
	StatusCode           string            `json:"StatusCode"`

	StartTime time.Time `json:"StartTime"`
	EndTime   time.Time `json:"EndTime"`
}

AutoScalingGroupDetail of the triggered event

type EC2Detail

type EC2Detail struct {
	InstanceID string `json:"instance-id"`
	State      string `json:"state"`
}

EC2Detail of the triggered event

type Event

type Event struct {
	ID         string          `json:"id"`
	DetailType string          `json:"detail-type"`
	Source     string          `json:"source"`
	Account    string          `json:"account"`
	Time       time.Time       `json:"time"`
	Region     string          `json:"region"`
	Resources  []string        `json:"resources"`
	Detail     json.RawMessage `json:"detail"`
}

Event represents a CloudWatch Event

type Handler

type Handler interface {
	HandleCloudWatcEvent(*Event, *apex.Context) error
}

Handler handles CloudWatch Events

type HandlerFunc

type HandlerFunc func(*Event, *apex.Context) error

HandlerFunc unmarshals CloudWatch Events before passing control.

func (HandlerFunc) Handle

func (h HandlerFunc) Handle(data json.RawMessage, ctx *apex.Context) (interface{}, error)

Handle implements apex.Handler.

type UserIdentity

type UserIdentity struct {
	Type           string            `json:"type,omitempty"`
	PrincipleID    string            `json:"principalId,omitempty"`
	ARN            string            `json:"arn,omitempty"`
	AccountID      string            `json:"accountId,omitempty"`
	SessionContext map[string]string `json:"sessionContext,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL