lambda

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

README

Lambda Service

This service is github.com/aws/aws-sdk-go/service/lambda.Lambda proxy

To check all supported method run

    endly -s="aws/lambda"

To check method contract run endly -s="aws/lambda" -a=methodName

    endly -s="aws/lambda" -a=createFunction

On top of that service implements the following helper methods:

  • recreateFunction: drop if exists and create new function
  • dropFunction: drop function with dependencies
  • setupPermission: add permission if it does not exists
  • setupFunction: creates or modifies function with specified policies
Usage:
Create function

Deployoment with recreateFunction

endly -r=setup

@setup.yaml

init:
  functionRole: lambda-helloworld-executor
  functionName: HelloWorld
  codeZip: /tmp/hello/main.zip
  awsCredentials: aws
pipeline:
  deploy:
    build:
      action: exec:run
      target: $target
      sleepTimeMs: 1500
      errors:
        - ERROR
      commands:
        - cd /tmp/hello
        - export GOOS=linux
        - export GOARCH=amd64
        - go build -o main
        - zip -j main.zip main
    createRole:
      credentials: $awsCredentials
      action: aws/iam:recreateRole
      rolename: $functionRole
      assumerolepolicydocument: $Cat('/tmp/hello/trust-policy.json')
    attachPolicy:
      action: aws/iam:attachRolePolicy
      comments: attaching policy to ${createRole.Role.Arn}
      rolename: $functionRole
      policyarn: arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      sleepTimeMs: 10000
    createFunction:
      action: aws/lambda:recreateFunction
      role: $createRole.Role.Arn
      functionname: ${functionName}
      runtime:  go1.x
      handler: main
      code:
        zipfile: $LoadBinary($codeZip)

Deployoment with setupFunction

@setup.yaml

init:
  functionRole: lambda-helloworld-executor
  functionName: HelloWorld
  codeZip: /tmp/hello/main.zip
  awsCredentials: aws
pipeline:
  deploy:
   build:
      action: exec:run
      target: $target
      sleepTimeMs: 1500
      errors:
        - ERROR
      commands:
        - cd ${appPath}loginfo/app
        - unset GOPATH
        - export GOOS=linux
        - export GOARCH=amd64
        - go build -o loginfo
        - zip -j loginfo.zip loginfo

    setupFunction:
      action: aws/lambda:deploy
      credentials: $awsCredentials
      functionname: $functionName
      runtime:  go1.x
      handler: loginfo
      code:
        zipfile: $LoadBinary(${codeZip})
      rolename: lambda-loginfo-executor
      define:
        - policyname: s3-mye2e-bucket-role
          policydocument: $Cat('${privilegePolicy}')
      attach:
        - policyarn: arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Invoke function
endly -r=trigger

@trigger.yaml

init:
  functionName: HelloWorld
  awsCredentials: aws
pipeline:
  trigger:
    action: aws/lambda:invoke
    credentials: $awsCredentials
    comments: call $functionName lambda function
    functionname: $functionName
    payload: ""
    post:
      payload: $AsString($Payload)
  assert:
    action: validator:assert
    comments: 'validate function output: $payload '
    actual: $payload
    expected: /Hello World/

Documentation

Index

Constants

View Source
const DefaultTrustPolicy = `` /* 193-byte string literal not displayed */

DefaultTrustPolicy represents default trust policy

View Source
const (
	//ServiceID aws lambda service id.
	ServiceID = "aws/lambda"
)

Variables

This section is empty.

Functions

func GetClient

func GetClient(context *endly.Context) (*lambda.Lambda, error)

GetClient returns lambda client from context

func New

func New() endly.Service

New creates a new AWS Ec2 service.

Types

type CallInput added in v0.29.0

type CallInput lambda.InvokeInput

CallInput represents a call request

type CallOutput added in v0.29.0

type CallOutput struct {
	*lambda.InvokeOutput
	Response interface{}
}

CallOutput represents a call response

type DeployInput added in v0.29.0

type DeployInput struct {
	lambda.CreateFunctionInput
	ciam.SetupRolePolicyInput
	Triggers []*EventSourceMapping
}

DeployInput setup function, creates or updates existing one

func (*DeployInput) Init added in v0.29.0

func (i *DeployInput) Init() error

func (*DeployInput) Validate added in v0.29.0

func (i *DeployInput) Validate() error

type DeployOutput added in v0.29.0

type DeployOutput struct {
	*lambda.FunctionConfiguration
	RoleInfo      *ciam.GetRoleInfoOutput
	EventMappings []*lambda.EventSourceMappingConfiguration
}

func (*DeployOutput) Messages added in v0.29.0

func (i *DeployOutput) Messages() []*msg.Message

type DropFunctionInput

type DropFunctionInput lambda.DeleteFunctionInput

DropFunctionInput remove a function with all dependencies

type EventSourceMapping

type EventSourceMapping struct {
	Source                    string
	Type                      string
	SourceARN                 *string
	Enabled                   *bool
	BatchSize                 *int64     `min:"1" type:"integer"`
	StartingPosition          *string    `type:"string" enum:"EventSourcePosition"`
	StartingPositionTimestamp *time.Time `type:"timestamp"`
}

type EventTriggerInfo

type EventTriggerInfo struct {
	// The identifier of the event source mapping.
	UUID *string `yaml:"uuid,omitempty" type:"string"`

	// The maximum number of items to retrieve in a single batch.
	BatchSize *int64 `yaml:"batchSize,omitempty" min:"1" type:"integer"`

	// The Amazon Resource Name (ARN) of the event source.
	EventSourceArn *string `yaml:"sourceARN,omitempty" type:"string"`

	// The date that the event source mapping was last updated, in Unix time seconds.
	LastModified *time.Time `yaml:"modified,omitempty" type:"timestamp"`

	// The result of the last AWS Lambda invocation of your Lambda function.
	LastProcessingResult *string `yaml:"lastProcessingResult,omitempty" type:"string"`

	// The state of the event source mapping. It can be one of the following: Creating,
	// Enabling, Enabled, Disabling, Disabled, Updating, or Deleting.
	State *string `yaml:"state,omitempty" type:"string"`

	// The cause of the last state change, either User initiated or Lambda initiated.
	StateTransitionReason *string `yaml:"stateTransitionReason,omitempty" type:"string"`
}

type FunctionInfo

type FunctionInfo struct {
	Name string
	Arn  string
}

type RecreateFunctionInput

type RecreateFunctionInput lambda.CreateFunctionInput

RecreateFunctionInput drops function if exist to create a new one

type SetupFunctionEvent

type SetupFunctionEvent struct {
	Function *FunctionInfo
	Triggers []*EventTriggerInfo `yaml:"triggers,omitempty"`
}

func NewSetupFunctionEvent

func NewSetupFunctionEvent(output *DeployOutput) *SetupFunctionEvent

func (*SetupFunctionEvent) Messages

func (e *SetupFunctionEvent) Messages() []*msg.Message

type SetupPermissionInput

type SetupPermissionInput lambda.AddPermissionInput

SetupPermissionInput creates a permission if it does not exists

type SetupTriggerSourceInput

type SetupTriggerSourceInput struct {
	FunctionName *string
	Triggers     []*EventSourceMapping
}

SetupTriggerSourceInput represents setup triggers input

func (*SetupTriggerSourceInput) Validate

func (i *SetupTriggerSourceInput) Validate() error

type SetupTriggerSourceOutput

type SetupTriggerSourceOutput struct {
	EventMappings []*lambda.EventSourceMappingConfiguration
}

SetupTriggerSourceOutput represents setup triggers output

Jump to

Keyboard shortcuts

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