events

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 7 Imported by: 5,560

README

Overview

This package provides input types for Lambda functions that process AWS events.

Samples

API Gateway

Cognito Events

Config Events

DynamoDB Events

Kinesis Events

Kinesis Firehose Events

S3 Events

SNS Events

Documentation

Index

Constants

View Source
const (
	KinesisFirehoseTransformedStateOk               = "TRANSFORMED_STATE_OK"
	KinesisFirehoseTransformedStateDropped          = "TRANSFORMED_STATE_DROPPED"
	KinesisFirehoseTransformedStateProcessingFailed = "TRANSFORMED_STATE_PROCESSINGFAILED"
)

Constants used for describing the transformation result

Variables

This section is empty.

Functions

This section is empty.

Types

type APIGatewayCustomAuthorizerContext

type APIGatewayCustomAuthorizerContext struct {
	PrincipalID *string `json:"principalId"`
	StringKey   *string `json:"stringKey,omitempty"`
	NumKey      *int    `json:"numKey,omitempty"`
	BoolKey     *bool   `json:"boolKey,omitempty"`
}

APIGatewayCustomAuthorizerContext represents the expected format of an API Gateway custom authorizer response.

type APIGatewayProxyRequest

type APIGatewayProxyRequest struct {
	Resource              string                        `json:"resource"` // The resource path defined in API Gateway
	Path                  string                        `json:"path"`     // The url path for the caller
	HTTPMethod            string                        `json:"httpMethod"`
	Headers               map[string]string             `json:"headers"`
	QueryStringParameters map[string]string             `json:"queryStringParameters"`
	PathParameters        map[string]string             `json:"pathParameters"`
	StageVariables        map[string]string             `json:"stageVariables"`
	RequestContext        APIGatewayProxyRequestContext `json:"requestContext"`
	Body                  string                        `json:"body"`
	IsBase64Encoded       bool                          `json:"isBase64Encoded,omitempty"`
}

APIGatewayProxyRequest contains data coming from the API Gateway proxy

type APIGatewayProxyRequestContext

type APIGatewayProxyRequestContext struct {
	AccountID    string                    `json:"accountId"`
	ResourceID   string                    `json:"resourceId"`
	Stage        string                    `json:"stage"`
	RequestID    string                    `json:"requestId"`
	Identity     APIGatewayRequestIdentity `json:"identity"`
	ResourcePath string                    `json:"resourcePath"`
	HTTPMethod   string                    `json:"httpMethod"`
	APIID        string                    `json:"apiId"` // The API Gateway rest API Id
}

APIGatewayProxyRequestContext contains the information to identify the AWS account and resources invoking the Lambda function. It also includes Cognito identity information for the caller.

type APIGatewayProxyResponse

type APIGatewayProxyResponse struct {
	StatusCode      int               `json:"statusCode"`
	Headers         map[string]string `json:"headers"`
	Body            string            `json:"body"`
	IsBase64Encoded bool              `json:"isBase64Encoded,omitempty"`
}

APIGatewayProxyResponse configures the response to be returned by API Gateway for the request

type APIGatewayRequestIdentity

type APIGatewayRequestIdentity struct {
	CognitoIdentityPoolID         string `json:"cognitoIdentityPoolId"`
	AccountID                     string `json:"accountId"`
	CognitoIdentityID             string `json:"cognitoIdentityId"`
	Caller                        string `json:"caller"`
	APIKey                        string `json:"apiKey"`
	SourceIP                      string `json:"sourceIp"`
	CognitoAuthenticationType     string `json:"cognitoAuthenticationType"`
	CognitoAuthenticationProvider string `json:"cognitoAuthenticationProvider"`
	UserArn                       string `json:"userArn"`
	UserAgent                     string `json:"userAgent"`
	User                          string `json:"user"`
}

APIGatewayRequestIdentity contains identity information for the request caller.

type CognitoDatasetRecord

type CognitoDatasetRecord struct {
	NewValue string `json:"newValue"`
	OldValue string `json:"oldValue"`
	Op       string `json:"op"`
}

CognitoDatasetRecord represents a record from an AWS Cognito event

type CognitoEvent

type CognitoEvent struct {
	DatasetName    string                          `json:"datasetName"`
	DatasetRecords map[string]CognitoDatasetRecord `json:"datasetRecords"`
	EventType      string                          `json:"eventType"`
	IdentityID     string                          `json:"identityId"`
	IdentityPoolID string                          `json:"identityPoolId"`
	Region         string                          `json:"region"`
	Version        int                             `json:"version"`
}

CognitoEvent contains data from an event sent from AWS Cognito

type ConfigEvent

type ConfigEvent struct {
	AccountID        string `json:"accountId"`     // The ID of the AWS account that owns the rule
	ConfigRuleArn    string `json:"configRuleArn"` // The ARN that AWS Config assigned to the rule
	ConfigRuleID     string `json:"configRuleId"`
	ConfigRuleName   string `json:"configRuleName"` // The name that you assigned to the rule that caused AWS Config to publish the event
	EventLeftScope   bool   `json:"eventLeftScope"` // A boolean value that indicates whether the AWS resource to be evaluated has been removed from the rule's scope
	ExecutionRoleArn string `json:"executionRoleArn"`
	InvokingEvent    string `json:"invokingEvent"`  // If the event is published in response to a resource configuration change, this value contains a JSON configuration item
	ResultToken      string `json:"resultToken"`    // A token that the function must pass to AWS Config with the PutEvaluations call
	RuleParameters   string `json:"ruleParameters"` // Key/value pairs that the function processes as part of its evaluation logic
	Version          string `json:"version"`
}

ConfigEvent contains data from an event sent from AWS Config

type DynamoDBAttributeValue

type DynamoDBAttributeValue struct {
	// contains filtered or unexported fields
}

DynamoDBAttributeValue provides convenient access for a value stored in DynamoDB. For more information, please see http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html

func NewStringAttribute

func NewStringAttribute(value string) DynamoDBAttributeValue

NewStringAttribute creates an DynamoDBAttributeValue containing a String

func (DynamoDBAttributeValue) Binary

func (av DynamoDBAttributeValue) Binary() []byte

Binary provides access to an attribute of type Binary. Method panics if the attribute is not of type Binary.

func (DynamoDBAttributeValue) BinarySet

func (av DynamoDBAttributeValue) BinarySet() [][]byte

BinarySet provides access to an attribute of type Binary Set. Method panics if the attribute is not of type BinarySet.

func (DynamoDBAttributeValue) Boolean

func (av DynamoDBAttributeValue) Boolean() bool

Boolean provides access to an attribute of type Boolean. Method panics if the attribute is not of type Boolean.

func (DynamoDBAttributeValue) DataType

DataType provides access to the DynamoDB type of the attribute

func (DynamoDBAttributeValue) Float

func (av DynamoDBAttributeValue) Float() (float64, error)

Float provides access to an attribute of type Number. DynamoDB sends the values as strings. For convenience this method provides conversion to float64. The returned value is the nearest floating point number rounded using IEEE754 unbiased rounding. If the number is more than 1/2 ULP away from the largest floating point number of the given size, the value returned is ±Inf, err.Err = ErrRange. Method panics if the attribute is not of type Number.

func (DynamoDBAttributeValue) Integer

func (av DynamoDBAttributeValue) Integer() (int64, error)

Integer provides access to an attribute of type Number. DynamoDB sends the values as strings. For convenience this method provides conversion to int. If the value cannot be represented by a signed integer, err.Err = ErrRange and the returned value is the maximum magnitude integer of an int64 of the appropriate sign. Method panics if the attribute is not of type Number.

func (DynamoDBAttributeValue) IsNull

func (av DynamoDBAttributeValue) IsNull() bool

IsNull returns true if the attribute is of type Null.

func (DynamoDBAttributeValue) List

List provides access to an attribute of type List. Each element of the list is an DynamoDBAttributeValue itself. Method panics if the attribute is not of type List.

func (DynamoDBAttributeValue) Map

Map provides access to an attribute of type Map. They Keys are strings and the values are DynamoDBAttributeValue instances. Method panics if the attribute is not of type Map.

func (DynamoDBAttributeValue) MarshalJSON

func (av DynamoDBAttributeValue) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshaling to be used by the standard json/encoding package

func (DynamoDBAttributeValue) Number

func (av DynamoDBAttributeValue) Number() string

Number provides access to an attribute of type Number. DynamoDB sends the values as strings. For convenience please see also the methods Integer() and Float(). Method panics if the attribute is not of type Number.

func (DynamoDBAttributeValue) NumberSet

func (av DynamoDBAttributeValue) NumberSet() []string

NumberSet provides access to an attribute of type Number Set. DynamoDB sends the numbers as strings. Method panics if the attribute is not of type Number.

func (DynamoDBAttributeValue) String

func (av DynamoDBAttributeValue) String() string

String provides access to an attribute of type String. Method panics if the attribute is not of type String.

func (DynamoDBAttributeValue) StringSet

func (av DynamoDBAttributeValue) StringSet() []string

StringSet provides access to an attribute of type String Set. Method panics if the attribute is not of type String Set.

func (*DynamoDBAttributeValue) UnmarshalJSON

func (av *DynamoDBAttributeValue) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a JSON description of this DynamoDBAttributeValue

type DynamoDBDataType

type DynamoDBDataType int

DynamoDBDataType specifies the type supported natively by DynamoDB for an attribute

const (
	DataTypeBinary DynamoDBDataType = iota
	DataTypeBoolean
	DataTypeBinarySet
	DataTypeList
	DataTypeMap
	DataTypeNumber
	DataTypeNumberSet
	DataTypeNull
	DataTypeString
	DataTypeStringSet
)

type DynamoDBEvent

type DynamoDBEvent struct {
	Records []DynamoDBEventRecord `json:"Records"`
}

The DynamoDBEvent stream event handled to Lambda http://docs.aws.amazon.com/lambda/latest/dg/eventsources.html#eventsources-ddb-update

type DynamoDBEventRecord

type DynamoDBEventRecord struct {
	// The region in which the GetRecords request was received.
	AWSRegion string `json:"awsRegion"`

	// The main body of the stream record, containing all of the DynamoDB-specific
	// fields.
	Change DynamoDBStreamRecord `json:"dynamodb"`

	// A globally unique identifier for the event that was recorded in this stream
	// record.
	EventID string `json:"eventID"`

	// The type of data modification that was performed on the DynamoDB table:
	//
	//    * INSERT - a new item was added to the table.
	//
	//    * MODIFY - one or more of an existing item's attributes were modified.
	//
	//    * REMOVE - the item was deleted from the table
	EventName string `json:"eventName"`

	// The AWS service from which the stream record originated. For DynamoDB Streams,
	// this is aws:dynamodb.
	EventSource string `json:"eventSource"`

	// The version number of the stream record format. This number is updated whenever
	// the structure of Record is modified.
	//
	// Client applications must not assume that eventVersion will remain at a particular
	// value, as this number is subject to change at any time. In general, eventVersion
	// will only increase as the low-level DynamoDB Streams API evolves.
	EventVersion string `json:"eventVersion"`

	// The event source ARN of DynamoDB
	EventSourceArn string `json:"eventSourceARN"`
}

DynamoDbEventRecord stores information about each record of a DynamoDb stream event

type DynamoDBKeyType

type DynamoDBKeyType string
const (
	DynamoDBKeyTypeHash  DynamoDBKeyType = "HASH"
	DynamoDBKeyTypeRange DynamoDBKeyType = "RANGE"
)

type DynamoDBOperationType

type DynamoDBOperationType string
const (
	DynamoDBOperationTypeInsert DynamoDBOperationType = "INSERT"
	DynamoDBOperationTypeModify DynamoDBOperationType = "MODIFY"
	DynamoDBOperationTypeRemove DynamoDBOperationType = "REMOVE"
)

type DynamoDBSharedIteratorType

type DynamoDBSharedIteratorType string
const (
	DynamoDBShardIteratorTypeTrimHorizon         DynamoDBSharedIteratorType = "TRIM_HORIZON"
	DynamoDBShardIteratorTypeLatest              DynamoDBSharedIteratorType = "LATEST"
	DynamoDBShardIteratorTypeAtSequenceNumber    DynamoDBSharedIteratorType = "AT_SEQUENCE_NUMBER"
	DynamoDBShardIteratorTypeAfterSequenceNumber DynamoDBSharedIteratorType = "AFTER_SEQUENCE_NUMBER"
)

type DynamoDBStreamRecord

type DynamoDBStreamRecord struct {

	// The approximate date and time when the stream record was created, in UNIX
	// epoch time (http://www.epochconverter.com/) format.
	ApproximateCreationDateTime SecondsEpochTime `json:"ApproximateCreationDateTime,omitempty"`

	// The primary key attribute(s) for the DynamoDB item that was modified.
	Keys map[string]DynamoDBAttributeValue `json:"Keys,omitempty"`

	// The item in the DynamoDB table as it appeared after it was modified.
	NewImage map[string]DynamoDBAttributeValue `json:"NewImage,omitempty"`

	// The item in the DynamoDB table as it appeared before it was modified.
	OldImage map[string]DynamoDBAttributeValue `json:"OldImage,omitempty"`

	// The sequence number of the stream record.
	SequenceNumber string `json:"SequenceNumber"`

	// The size of the stream record, in bytes.
	SizeBytes int64 `json:"SizeBytes"`

	// The type of data from the modified DynamoDB item that was captured in this
	// stream record.
	StreamViewType string `json:"StreamViewType"`
}

A description of a single data modification that was performed on an item in a DynamoDB table.

type DynamoDBStreamStatus

type DynamoDBStreamStatus string
const (
	DynamoDBStreamStatusEnabling  DynamoDBStreamStatus = "ENABLING"
	DynamoDBStreamStatusEnabled   DynamoDBStreamStatus = "ENABLED"
	DynamoDBStreamStatusDisabling DynamoDBStreamStatus = "DISABLING"
	DynamoDBStreamStatusDisabled  DynamoDBStreamStatus = "DISABLED"
)

type DynamoDBStreamViewType

type DynamoDBStreamViewType string
const (
	DynamoDBStreamViewTypeNewImage        DynamoDBStreamViewType = "NEW_IMAGE"          // the entire item, as it appeared after it was modified.
	DynamoDBStreamViewTypeOldImage        DynamoDBStreamViewType = "OLD_IMAGE"          // the entire item, as it appeared before it was modified.
	DynamoDBStreamViewTypeNewAndOldImages DynamoDBStreamViewType = "NEW_AND_OLD_IMAGES" // both the new and the old item images of the item.
	DynamoDBStreamViewTypeKeysOnly        DynamoDBStreamViewType = "KEYS_ONLY"          // only the key attributes of the modified item.
)

type IncompatibleDynamoDBTypeError

type IncompatibleDynamoDBTypeError struct {
	Requested DynamoDBDataType
	Actual    DynamoDBDataType
}

IncompatibleDynamoDBTypeError is the error passed in a panic when calling an accessor for an incompatible type

func (IncompatibleDynamoDBTypeError) Error

type KinesisEvent

type KinesisEvent struct {
	Records []KinesisEventRecord `json:"Records"`
}

type KinesisEventRecord

type KinesisEventRecord struct {
	AwsRegion         string        `json:"awsRegion"`
	EventID           string        `json:"eventID"`
	EventName         string        `json:"eventName"`
	EventSource       string        `json:"eventSource"`
	EventSourceArn    string        `json:"eventSourceARN"`
	EventVersion      string        `json:"eventVersion"`
	InvokeIdentityArn string        `json:"invokeIdentityArn"`
	Kinesis           KinesisRecord `json:"kinesis"`
}

type KinesisFirehoseEvent

type KinesisFirehoseEvent struct {
	InvocationID      string                       `json:"invocationId"`
	DeliveryStreamArn string                       `json:"deliveryStreamArn"`
	Region            string                       `json:"region"`
	Records           []KinesisFirehoseEventRecord `json:"records"`
}

KinesisFirehoseEvent represents the input event from Amazon Kinesis Firehose. It is used as the input parameter.

type KinesisFirehoseEventRecord

type KinesisFirehoseEventRecord struct {
	RecordID                    string                `json:"recordId"`
	ApproximateArrivalTimestamp MilliSecondsEpochTime `json:"approximateArrivalTimestamp"`
	Data                        []byte                `json:"data"`
}

type KinesisFirehoseResponse

type KinesisFirehoseResponse struct {
	Records []KinesisFirehoseResponseRecord `json:"records"`
}

type KinesisFirehoseResponseRecord

type KinesisFirehoseResponseRecord struct {
	RecordID string `json:"recordId"`
	Result   string `json:"result"` // The status of the transformation. May be TransformedStateOk, TransformedStateDropped or TransformedStateProcessingFailed
	Data     []byte `json:"data"`
}

type KinesisRecord

type KinesisRecord struct {
	ApproximateArrivalTimestamp SecondsEpochTime `json:"approximateArrivalTimestamp"`
	Data                        []byte           `json:"data"`
	EncryptionType              string           `json:"encryptionType,omitempty"`
	PartitionKey                string           `json:"partitionKey"`
	SequenceNumber              string           `json:"sequenceNumber"`
	KinesisSchemaVersion        string           `json:"kinesisSchemaVersion"`
}

type MilliSecondsEpochTime

type MilliSecondsEpochTime struct {
	time.Time
}

MilliSecondsEpochTime serializes a time.Time in JSON as a UNIX epoch time in milliseconds.

func (MilliSecondsEpochTime) MarshalJSON

func (e MilliSecondsEpochTime) MarshalJSON() ([]byte, error)

func (*MilliSecondsEpochTime) UnmarshalJSON

func (e *MilliSecondsEpochTime) UnmarshalJSON(b []byte) error

type S3Bucket

type S3Bucket struct {
	Name          string         `json:"name"`
	OwnerIdentity S3UserIdentity `json:"ownerIdentity"`
	Arn           string         `json:"arn"`
}

type S3Entity

type S3Entity struct {
	SchemaVersion   string   `json:"s3SchemaVersion"`
	ConfigurationID string   `json:"configurationId"`
	Bucket          S3Bucket `json:"bucket"`
	Object          S3Object `json:"object"`
}

type S3Event

type S3Event struct {
	Records []S3EventRecord `json:"Records"`
}

type S3EventRecord

type S3EventRecord struct {
	EventVersion      string              `json:"eventVersion"`
	EventSource       string              `json:"eventSource"`
	AWSRegion         string              `json:"awsRegion"`
	EventTime         time.Time           `json:"eventTime"`
	EventName         string              `json:"eventName"`
	PrincipalID       S3UserIdentity      `json:"userIdentity"`
	RequestParameters S3RequestParameters `json:"requestParameters"`
	ResponseElements  map[string]string   `json:"responseElements"`
	S3                S3Entity            `json:"s3"`
}

type S3Object

type S3Object struct {
	Key           string `json:"key"`
	Size          int64  `json:"size"`
	URLDecodedKey string `json:"urlDecodedKey"`
	VersionID     string `json:"versionId"`
	ETag          string `json:"eTag"`
	Sequencer     string `json:"sequencer"`
}

type S3RequestParameters

type S3RequestParameters struct {
	SourceIPAddress string `json:"sourceIPAddress"`
}

type S3UserIdentity

type S3UserIdentity struct {
	PrincipalID string `json:"principalId"`
}

type SNSEntity

type SNSEntity struct {
	Signature         string                 `json:"Signature"`
	MessageID         string                 `json:"MessageId"`
	Type              string                 `json:"Type"`
	TopicArn          string                 `json:"TopicArn"`
	MessageAttributes map[string]interface{} `json:"MessageAttributes"`
	SignatureVersion  string                 `json:"SignatureVersion"`
	Timestamp         time.Time              `json:"Timestamp"`
	SigningCertURL    string                 `json:"SigningCertUrl"`
	Message           string                 `json:"Message"`
	UnsubscribeURL    string                 `json:"UnsubscribeUrl"`
	Subject           string                 `json:"Subject"`
}

type SNSEvent

type SNSEvent struct {
	Records []SNSEventRecord `json:"Records"`
}

type SNSEventRecord

type SNSEventRecord struct {
	EventVersion         string    `json:"EventVersion"`
	EventSubscriptionArn string    `json:"EventSubscriptionArn"`
	EventSource          string    `json:"EventSource"`
	SNS                  SNSEntity `json:"Sns"`
}

type SecondsEpochTime

type SecondsEpochTime struct {
	time.Time
}

SecondsEpochTime serializes a time.Time in JSON as a UNIX epoch time in seconds

func (SecondsEpochTime) MarshalJSON

func (e SecondsEpochTime) MarshalJSON() ([]byte, error)

func (*SecondsEpochTime) UnmarshalJSON

func (e *SecondsEpochTime) UnmarshalJSON(b []byte) error

type UnsupportedDynamoDBTypeError

type UnsupportedDynamoDBTypeError struct {
	Type string
}

UnsupportedDynamoDBTypeError is the error returned when trying to unmarshal a DynamoDB Attribute type not recognized by this library

func (UnsupportedDynamoDBTypeError) Error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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