kvtojson

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

kv-to-json

Build Status - master

Overview

kv-to-json accepts a document (typically submitted to AWS API Gateway via HTTP POST), converts to JSON, and submits to AWS SNS.

Input Format

The input document is expected to follow a simple key=value format. Each line consists of a key (alphanumeric characters), followed by a colon, followed by the value. Each key-value pair is separated by a newline. Spaces are not allowed in keys. The first colon encountered ends the key. Leading whitespace in the value will be dropped. Trailing whitespace will be maintained (for now - subject to change). Invalid lines will be quietly ignored (dropped).

The document is in two sections, header key-values and message key-values. The two sections are separated by a blank line.

Example doc:

X-secret: abcdef

key1: value1
key2: value number two

Build ZIP for AWS Lambda

BUILD_DT=`date +%FT%T%z`
COMMIT=`git rev-parse --short HEAD`
FULL_COMMIT=`git log -1`
VER=0.0.0
go get github.com/aws/aws-lambda-go/lambda \
  && GOOS=linux GOARCH=amd64 go build -o lambda -ldflags \
    "-X main.buildDt=${BUILD_DT} -X main.commit=${COMMIT} -X main.version=${VER}" \
    cmd/lambda/main.go \
  && go test ./... \
  && zip kv-to-json-${VER}.zip lambda
Upload Lambda Code to S3
aws s3 cp kv-to-json-${VER}.zip s3://PACKAGE_BUCKET_NAME
Manually Update Lambda Code (dev/test)
aws lambda update-function-code --function-name kv-to-json \
  --zip-file fileb://kv-to-json-${VER}.zip

Run Individual Test (disable cache)

go test ./... -count=1 -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sess

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

func New

func New(
	messageSender logevent.MessageSender,
	snsTopicArn string,
) *Sess

func (*Sess) SendOne

func (self *Sess) SendOne(logEvent logevent.LogEvent) error

Directories

Path Synopsis
cmd
cli command
lambda command
internal

Jump to

Keyboard shortcuts

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