github.com/mweagle/Sparta@v1.15.0/archetype/firehose_awsbinary.go (about)

     1  // +build lambdabinary
     2  
     3  package archetype
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     8  	"io/ioutil"
     9  	"os"
    10  
    11  	awsEvents "github.com/aws/aws-lambda-go/events"
    12  )
    13  
    14  var (
    15  	xformTemplateBytes []byte
    16  	xformError         error
    17  )
    18  
    19  func init() {
    20  	xformPath := os.Getenv(envVarKinesisFirehoseTransformName)
    21  	fmt.Printf("Reading template file: %s\n", xformPath)
    22  	templateBytes, templateBytesErr := ioutil.ReadFile(xformPath)
    23  	if templateBytesErr != nil {
    24  		xformError = templateBytesErr
    25  		return
    26  	}
    27  	xformTemplateBytes = templateBytes
    28  }
    29  
    30  // Great, transform everything
    31  func lambdaXForm(ctx context.Context, kinesisEvent awsEvents.KinesisFirehoseEvent) (*awsEvents.KinesisFirehoseResponse, error) {
    32  
    33  	if xformError != nil {
    34  		return nil, xformError
    35  	}
    36  	return ApplyTransformToKinesisFirehoseEvent(ctx, xformTemplateBytes, kinesisEvent)
    37  }