lambda

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MPL-2.0 Imports: 34 Imported by: 0

README

AWS Lambda

The AWS Lambda plugin deploys OCI images as functions to AWS Lambda.

Components

  1. Platform
  1. Docker
  2. AWS ECR
  3. AWS Lambda Function URL

Documentation

Overview

Package lambda contains components for deploying to AWS Lambda

Index

Constants

View Source
const (
	// The default amount of memory to give to the function invocation, 256MB
	DefaultMemory = 256

	// How long the function should run before terminating it.
	DefaultTimeout = 60

	// The instruction set architecture that the function supports.
	DefaultArchitecture = lambda.ArchitectureX8664

	// The storage size (in MB) for the function's `/tmp` directory
	DefaultStorageSize = 512
)

Variables

View Source
var File_waypoint_builtin_aws_lambda_plugin_proto protoreflect.FileDescriptor
View Source
var Options = []sdk.Option{
	sdk.WithComponents(&Platform{}),
}

Options are the SDK options to use for instantiation for the Google Cloud Run plugin.

Functions

func DockerArchitectureMapper added in v0.8.0

func DockerArchitectureMapper(src string, log hclog.Logger) string

DockerArchitectureMapper maps a docker image architecture to a valid lambda architecture.

Types

type Config

type Config struct {
	// The AWS region to create the Lambda function in
	Region string `hcl:"region"`

	// The IAM role to associate with the Lambda, specified by ARN. If no value is provided,
	// a role will be generated automatically.
	RoleArn string `hcl:"iam_role,optional"`

	// The amount of memory, measured in megabytes, to allocate the function.
	// Defaults to 256
	Memory int `hcl:"memory,optional"`

	// The number of seconds to wait for a function to complete it's work.
	// Defaults to 60
	Timeout int `hcl:"timeout,optional"`

	// The instruction set architecture that the function supports.
	// Valid values are: "x86_64", "arm64"
	// Defaults to "x86_64".
	Architecture string `hcl:"architecture,optional"`

	// The storage size (in MB) of the Lambda function's `/tmp` directory.
	// Must be a value between 512 and 10240.
	// Defaults to 512 MB.
	StorageMB int `hcl:"storagemb,optional"`

	// Environment variables that are meant to configure the application in a static
	// way. This might be control an image that has multiple modes of operation,
	// selected via environment variable. Most configuration should use the waypoint
	// config commands.
	StaticEnvVars map[string]string `hcl:"static_environment,optional"`
}

Config is the configuration structure for the Platform. Validation tags are provided by Go Pkg Validator https://pkg.go.dev/gopkg.in/go-playground/validator.v10?tab=doc

type Deployment

type Deployment struct {

	// Identifier for the deployment, required by Waypoint
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The AWS region the function is deployed in
	Region string `protobuf:"bytes,3,opt,name=region,proto3" json:"region,omitempty"`
	// The ARN for the Lambda function itself.
	FuncArn string `protobuf:"bytes,4,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"`
	// The ARN for the version of the Lambda function this deployment uses.
	VerArn string `protobuf:"bytes,5,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"`
	// The ARN of the TargetGroup created for ver_arn
	TargetGroupArn string `protobuf:"bytes,6,opt,name=target_group_arn,json=targetGroupArn,proto3" json:"target_group_arn,omitempty"`
	// The version identifier AWS uses for this version (basically a serial increasing number)
	Version string `protobuf:"bytes,7,opt,name=version,proto3" json:"version,omitempty"`
	// The storage size (in MB) of the Lambda function's `/tmp` directory.
	// Must be a value between 512 and 10240.
	Storage int64 `protobuf:"varint,8,opt,name=storage,proto3" json:"storage,omitempty"`
	// contains filtered or unexported fields
}

func (*Deployment) Descriptor deprecated

func (*Deployment) Descriptor() ([]byte, []int)

Deprecated: Use Deployment.ProtoReflect.Descriptor instead.

func (*Deployment) GetFuncArn

func (x *Deployment) GetFuncArn() string

func (*Deployment) GetId

func (x *Deployment) GetId() string

func (*Deployment) GetRegion

func (x *Deployment) GetRegion() string

func (*Deployment) GetStorage added in v0.11.0

func (x *Deployment) GetStorage() int64

func (*Deployment) GetTargetGroupArn

func (x *Deployment) GetTargetGroupArn() string

func (*Deployment) GetVerArn

func (x *Deployment) GetVerArn() string

func (*Deployment) GetVersion

func (x *Deployment) GetVersion() string

func (*Deployment) ProtoMessage

func (*Deployment) ProtoMessage()

func (*Deployment) ProtoReflect

func (x *Deployment) ProtoReflect() protoreflect.Message

func (*Deployment) Reset

func (x *Deployment) Reset()

func (*Deployment) String

func (x *Deployment) String() string

type Platform

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

Platform is the Platform implementation for AWS Lambda

func (*Platform) Auth

func (p *Platform) Auth() error

func (*Platform) AuthFunc

func (p *Platform) AuthFunc() interface{}

AuthFunc implements component.Authenticator

func (*Platform) Config

func (p *Platform) Config() (interface{}, error)

Config implements Configurable

func (*Platform) ConfigSet

func (p *Platform) ConfigSet(config interface{}) error

ConfigSet is called after a configuration has been decoded we can use this to validate the config

func (*Platform) Deploy

func (p *Platform) Deploy(
	ctx context.Context,
	log hclog.Logger,
	src *component.Source,
	img *ecr.Image,
	deployConfig *component.DeploymentConfig,
	ui terminal.UI,
) (*Deployment, error)

Deploy deploys an image to AWS Lambda.

func (*Platform) DeployFunc

func (p *Platform) DeployFunc() interface{}

DeployFunc implements component.Platform

func (*Platform) Destroy

func (p *Platform) Destroy(
	ctx context.Context,
	log hclog.Logger,
	deployment *Deployment,
	ui terminal.UI,
) error

Destroy deletes the AWS Lambda revision

func (*Platform) DestroyFunc

func (p *Platform) DestroyFunc() interface{}

DestroyFunc implements component.Destroyer

func (*Platform) DestroyWorkspace

func (p *Platform) DestroyWorkspace(
	ctx context.Context,
	log hclog.Logger,
	deployment *Deployment,
	app *component.Source,
	ui terminal.UI,
) error

DestroyWorkspace deletes other bits we created

func (*Platform) DestroyWorkspaceFunc

func (p *Platform) DestroyWorkspaceFunc() interface{}

DestroyWorkspaceFunc implements component.WorkspaceDestroyer

func (*Platform) Documentation

func (p *Platform) Documentation() (*docs.Documentation, error)

func (*Platform) Exec

func (p *Platform) Exec(
	ctx context.Context,
	log hclog.Logger,
	deployment *Deployment,
	image *ecr.Image,
	ui terminal.UI,
	es *component.ExecSessionInfo,
	app *component.Source,
) (*component.ExecResult, error)

Exec creates an ECS task using the given deployments ECR image and then ssh's to it to provide the shell.

func (*Platform) ExecFunc

func (p *Platform) ExecFunc() interface{}

ExecFunc implements component.Execer

func (*Platform) Logs

func (p *Platform) Logs(
	ctx context.Context,
	log hclog.Logger,
	ui terminal.UI,
	es *component.LogViewer,
	app *component.Source,
	dep *Deployment,
) error

Logs fetches logs from cloudwatch

func (*Platform) LogsFunc

func (p *Platform) LogsFunc() interface{}

LogsFunc implements component.LogsPlatform

func (*Platform) ValidateAuth

func (p *Platform) ValidateAuth(
	ctx context.Context,
	log hclog.Logger,
	src *component.Source,
	ui terminal.UI,
) error

TODO sort out the right way to validate AWS config and use it in all the AWS types

func (*Platform) ValidateAuthFunc

func (p *Platform) ValidateAuthFunc() interface{}

ValidateAuthFunc implements component.Authenticator

type TaskInfo

type TaskInfo struct {
	IP  string
	Arn string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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