Documentation ¶
Index ¶
- Variables
- func CFResource(ctx context.Context, e CFEvent) (string, error)
- func CFResourceCreate(ctx context.Context, e CFEvent, props map[string]string) (string, error)
- func CFResourceDelete(ctx context.Context, e CFEvent, props map[string]string) (string, error)
- func CFResourceUpdate(ctx context.Context, e CFEvent, props map[string]string) (string, error)
- func CFRespond(ctx context.Context, e CFEvent) error
- func Dashboard(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func JWTClaims(e events.APIGatewayProxyRequest, claims jwt.Claims) (events.APIGatewayProxyResponse, jwt.Claims, error)
- func NewAPIGateway() *apigateway.APIGateway
- func NewLambda() *lambda.Lambda
- func NewS3() *s3.S3
- func NewSNS() *sns.SNS
- func UserCreate(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func UserDelete(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func UserRead(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func UserUpdate(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func WorkCreate(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
- func Worker(ctx context.Context, e WorkerEvent) error
- func WorkerPeriodic(ctx context.Context, e events.CloudWatchEvent) error
- type CFEvent
- type CFResponse
- type DynamoDBAPI
- type HandlerAPIGateway
- type HandlerCloudWatch
- type HandlerWorker
- type KMSAPI
- type ResponseError
- type User
- type WorkerEvent
Constants ¶
This section is empty.
Variables ¶
var ( APIGateway = NewAPIGateway() DynamoDB = NewDynamoDB() KMS = NewKMS() Lambda = NewLambda() S3 = NewS3() SNS = NewSNS() )
AWS Clients that can be mocked for testing
var UUIDGen = func() uuid.UUID {
return uuid.NewV4()
}
UUIDGen is a UUID generator that can be mocked for testing
Functions ¶
func CFResource ¶
CFResource dispatches a CloudFormation Custom Resource event to a create, update or delete function
func CFResourceCreate ¶
CFResourceCreate creates a custom resource and returns a new PhysicalResourceID This delegates to ResourceUpdate since there are no resources to create
func CFResourceDelete ¶
CFResourceDelete deletes a custom resource and returns its old PhysicalResourceID This delegates to ResourceUpdate since there are no resources to delete
func CFResourceUpdate ¶
CFResourceUpdate updates a custom resource and returns its existing PhysicalResourceID This toggles settings on the Stage specified by Stage and RestApiId parameters
func CFRespond ¶
CFRespond creates, updates or deletes a CloudFormation custom resource then PUTs the status to the given ResponseURL
func Dashboard ¶
func Dashboard(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Dashboard returns a dashboard HTML page
func JWTClaims ¶
func JWTClaims(e events.APIGatewayProxyRequest, claims jwt.Claims) (events.APIGatewayProxyResponse, jwt.Claims, error)
JWTClaims validates the token in the Authorization header It returns a response with standard headers and claims if valid And an error response and an error if invalid
func NewAPIGateway ¶
func NewAPIGateway() *apigateway.APIGateway
NewAPIGateway is an xray instrumented APIGateway client
func UserCreate ¶
func UserCreate(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
UserCreate creates a user
func UserDelete ¶
func UserDelete(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
UserDelete deletes a user by id
func UserRead ¶
func UserRead(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
UserRead returns a user by id
func UserUpdate ¶
func UserUpdate(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
UserUpdate updates a user by id
func WorkCreate ¶
func WorkCreate(ctx context.Context, e events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
WorkCreate invokes the worker func
func Worker ¶
func Worker(ctx context.Context, e WorkerEvent) error
Worker is invoked directly to perform work then upload a report to S3
func WorkerPeriodic ¶
func WorkerPeriodic(ctx context.Context, e events.CloudWatchEvent) error
WorkerPeriodic runs on a schedule to clean S3
Types ¶
type CFEvent ¶
type CFEvent struct { LogicalResourceID string `json:"LogicalResourceId"` OldResourceProperties json.RawMessage `json:"OldResourceProperties"` PhysicalResourceID string `json:"PhysicalResourceId"` RequestID string `json:"RequestId"` RequestType string `json:"RequestType"` ResourceProperties json.RawMessage `json:"ResourceProperties"` ResourceType string `json:"ResourceType"` ResponseURL string `json:"ResponseURL"` StackID string `json:"StackId"` }
CFEvent is a CloudFormation Custom Resource Event that Lambda is invoked with
type CFResponse ¶
type CFResponse struct { Data struct { Value string `json:"Value"` } LogicalResourceID string `json:"LogicalResourceId"` PhysicalResourceID string `json:"PhysicalResourceId"` Reason string `json:"Reason"` RequestID string `json:"RequestId"` StackID string `json:"StackId"` Status string `json:"Status"` }
CFResponse is a CloudFormation Custom Resource Response that is PUT to S3
type DynamoDBAPI ¶
type DynamoDBAPI interface { DeleteItemWithContext(ctx aws.Context, input *dynamodb.DeleteItemInput, opts ...request.Option) (*dynamodb.DeleteItemOutput, error) GetItemWithContext(ctx aws.Context, input *dynamodb.GetItemInput, opts ...request.Option) (*dynamodb.GetItemOutput, error) PutItemWithContext(ctx aws.Context, input *dynamodb.PutItemInput, opts ...request.Option) (*dynamodb.PutItemOutput, error) }
DynamoDBAPI is a subset of dynamodbiface.DynamoDBAPI
func NewDynamoDB ¶
func NewDynamoDB() DynamoDBAPI
NewDynamoDB is an xray instrumented DynamoDB client
type HandlerAPIGateway ¶
type HandlerAPIGateway func(context.Context, events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
HandlerAPIGateway is an API Gateway Proxy Request handler function
func NotifyAPIGateway ¶
func NotifyAPIGateway(h HandlerAPIGateway) HandlerAPIGateway
NotifyAPIGateway wraps a handler func and sends an SNS notification on error
type HandlerCloudWatch ¶
type HandlerCloudWatch func(context.Context, events.CloudWatchEvent) error
HandlerCloudWatch is a CloudWatchEvent handler function
func NotifyCloudWatch ¶
func NotifyCloudWatch(h HandlerCloudWatch) HandlerCloudWatch
NotifyCloudWatch wraps a handler func and sends an SNS notification on error
type HandlerWorker ¶
type HandlerWorker func(context.Context, WorkerEvent) error
HandlerWorker is a Worker handler function
func NotifyWorker ¶
func NotifyWorker(h HandlerWorker) HandlerWorker
NotifyWorker wraps a handler func and sends an SNS notification on error
type KMSAPI ¶
type KMSAPI interface { DecryptWithContext(ctx aws.Context, input *kms.DecryptInput, opts ...request.Option) (*kms.DecryptOutput, error) EncryptWithContext(ctx aws.Context, input *kms.EncryptInput, opts ...request.Option) (*kms.EncryptOutput, error) }
KMSAPI is a subset of kmsiface.KMSAPI
type ResponseError ¶
ResponseError is an error type that indicates a non-200 response
func (ResponseError) Error ¶
func (e ResponseError) Error() string
func (ResponseError) Response ¶
func (e ResponseError) Response() (events.APIGatewayProxyResponse, error)
Response returns an API Gateway Response event