Documentation ¶
Overview ¶
Package sls exposes behavior and types that are used to manage day to day development, deployment, inspecting and testing of serverless applications running is AWS
Index ¶
- Constants
- Variables
- func GetTraceID(ctx context.Context) string
- func InvocationLogger(ctx context.Context, l *zap.SugaredLogger, invType InvokeTrigger) *zap.SugaredLogger
- func NewDefaultConfig(opts ...context.Context) (aws.Config, error)
- func NewDefaultConfigMust(opts ...context.Context) aws.Config
- func NewDefaultConfigWithConf(c AWSConfig, opts ...context.Context) (aws.Config, error)
- func NewDefaultConfigWithProfile(profile string, opts ...context.Context) (aws.Config, error)
- func NewDefaultConfigWithRegion(reg string, opts ...context.Context) (aws.Config, error)
- func NewGoBuildCmd(buildDir, binaryName, targetDir string) (*exec.Cmd, error)
- func RegionCode(region string) string
- func Zip(zf, binary string) error
- type AWSAccount
- type AWSConfig
- type BuildResult
- type BuildSettings
- type CodeLayout
- type CompileResult
- type ConcreteHandlerFn
- type Configurable
- type Feature
- type FeatureDeployment
- type Features
- type GlobalResources
- type InvokeTrigger
- type KeyPair
- type MicroService
- func (s *MicroService) AddByTrigger(et InvokeTrigger) error
- func (s *MicroService) AddFeature(et InvokeTrigger, title string) error
- func (s *MicroService) BuildFeature(feature Feature, codeDir ...string) (*CompileResult, error)
- func (s *MicroService) BuildFeatureCode(buildDir, binaryName, sourceDir string) (*CompileResult, error)
- func (s *MicroService) Feature(title string) (Feature, error)
- func (s *MicroService) GoPath() (string, error)
- func (s *MicroService) LoadFeaturesFromFilesystem() error
- func (s *MicroService) NewBuildSettings(feature Feature) BuildSettings
- func (s *MicroService) String() string
- func (s *MicroService) UpdateEnvWithPStoreCmd(feature string) (*exec.Cmd, error)
- type MicroServiceIn
- type MockTimeout
- type Prefix
- type Protocol
- type Region
- type RegionConfig
- type Repo
- type ServiceName
- type TFBackend
- type TFResource
- type Terraform
- type Timeout
- type TimeoutCapturing
- type TimeoutConfig
- type VCS
Constants ¶
const ( GoBinaryName = "go" GoBuildCmdName = "build" DefaultLDFlags = `-ldflags="-s -w -X main.Version=$(git rev-parse HEAD)"` )
const ( UsEast1 = Region("us-east-1") UsEast2 = Region("us-east-2") UsWest1 = Region("us-west-1") UsWest2 = Region("us-west-2") AfSouth1 = Region("af-south-1") ApEast1 = Region("ap-east-1") ApSouth1 = Region("ap-south-1") ApNortheast1 = Region("ap-northeast-1") ApNortheast2 = Region("ap-northeast-2") ApNortheast3 = Region("ap-northeast-3") ApSoutheast1 = Region("ap-southeast-1") ApSoutheast2 = Region("ap-southeast-2") CaCentral1 = Region("ca-central-1") EuCentral1 = Region("eu-central-1") EuWest1 = Region("eu-west-1") EuWest2 = Region("eu-west-2") EuWest3 = Region("eu-west-3") EuSouth1 = Region("eu-south-1") EuNorth1 = Region("eu-north-1") MeSouth1 = Region("me-south-1") SaEast1 = Region("sa-east-1") UsGovEast1 = Region("us-gov-east-1") UsGovWest1 = Region("us-gov-west-1") )
const ( APIGWProxyTrigger = InvokeTrigger("apigw") APIGWCustomAuthTrigger = InvokeTrigger("apigw-auth") AppSyncTrigger = InvokeTrigger("appsync") CloudWatchEventTrigger = InvokeTrigger("cw-event") CloudWatchLogsTrigger = InvokeTrigger("cw-log") CognitoTrigger = InvokeTrigger("cognito") DDBTrigger = InvokeTrigger("ddb") DDBStreamTrigger = InvokeTrigger("ddb-stream") DirectTrigger = InvokeTrigger("direct") KinesisStreamTrigger = InvokeTrigger("kinesis-stream") SNSTrigger = InvokeTrigger("sns") SQSTrigger = InvokeTrigger("sqs") S3Trigger = InvokeTrigger("s3") StepTrigger = InvokeTrigger("sfn") )
const ( DefaultOutputName = "bootstrap" DefaultBinaryZipName = "deployment.zip" DefaultInfraDir = "infra/local" DefaultTerraform = "terraform" DefaultLambdasDir = "app/lambdas" DefaultBuildDir = "/tmp" DefaultRepoRefName = "main" DefaultLambdaInvokeType = "RequestResponse" DefaultLambdaInvokeLogType = "Tail" DefaultLambdaGoFile = "main.go" DefaultAppDirName = "app" DefaultLambdaDirName = "lambdas" DefaultInfraDirName = "infra" DefaultBuildDirName = "build" DefaultTerraformDirName = "terraform" LocalTerraformRepoName = "local-terraform" GithubURL = "github.com" TerraformName = "terraform" SSHProtocol = Protocol("ssh") HTTPSProtocol = Protocol("https") CLIProtocol = Protocol("cmds") CLITemplate = "%s/%s" SSHTemplate = "git@%s:%s/%s.git" HTTPSTemplate = "https://%s/%s/%s.git" RemoteStateTF = "remote-state" LambdaDeployTF = "lambda-deploy-bucket" KeyPairTF = "key-pair" MessagingTF = "messaging" CognitoTF = "cognito" NetworkingTF = "networking" )
const (
DefaultFeatureTimeout = 100
)
Variables ¶
var ( APIGWProxyEvent = reflect.TypeOf(events.APIGatewayProxyRequest{}) APIGWCustomAuthEvent = reflect.TypeOf(events.APIGatewayCustomAuthorizerRequest{}) CloudWatchEvent = reflect.TypeOf(events.CloudWatchEvent{}) CloudWatchLogsEvent = reflect.TypeOf(events.CloudwatchLogsEvent{}) DDBEvent = reflect.TypeOf(events.DynamoDBEvent{}) DirectEvent = reflect.TypeOf([]byte{}) SNSEvent = reflect.TypeOf(events.SNSEvent{}) SQSEvent = reflect.TypeOf(events.SQSEvent{}) S3Event = reflect.TypeOf(events.S3Event{}) )
var DefaultRegion = Region("us-east-1")
Functions ¶
func GetTraceID ¶ added in v0.2.0
GetTraceID gets the trace id from the context. The value is in the format of "Root=1-5abc5ca4-f07ab5d0a2c2b2f0730acb08;Parent=200406d9510e71a3;Sampled=0" and the root trace id is parsed out and returned.
func InvocationLogger ¶ added in v0.2.0
func InvocationLogger(ctx context.Context, l *zap.SugaredLogger, invType InvokeTrigger) *zap.SugaredLogger
InvocationLogger gets a logger with fields initialized for a particular invocation.
func NewDefaultConfig ¶ added in v0.2.0
NewDefaultConfig will return an aws.Config struct that can be used to configure most sdk clients. If no context is given this will create one
func NewDefaultConfigMust ¶ added in v0.2.0
NewDefaultConfigMust is the same as its cousin accept it will panic if it fails. This is useful in setup scenarios where you can not return any errors
func NewDefaultConfigWithConf ¶ added in v0.2.0
NewDefaultConfigWithConf will use the config.LoadDefaultConfig with various different options set by the conf package. An Empty struct will give you the default config.
func NewDefaultConfigWithProfile ¶ added in v0.2.0
NewDefaultConfigWithProfile just adds an aws profile to the configuration.
func NewDefaultConfigWithRegion ¶ added in v0.2.0
NewDefaultConfigWithRegion just adds a aws region to the configuration. NOTE: the region is validated and will fail if not a proper aws region
func NewGoBuildCmd ¶
NewGoBuildCmd is designed to compile golang source code used for AWS Lambdas, for us these are features in our microservices.
buildDir - directory the binary will be compiled to binaryName - is the name of the binary, this is used in the -o flag targetDir - is the directory which contains the source code to build
func RegionCode ¶
RegionCode takes an AWS region like us-east-1 and compresses into a smaller code like (us-east-1) -> (use1) which is used in resource naming
Types ¶
type AWSAccount ¶ added in v0.2.0
AWSAccount hold the profile used and the default region. We can use this to set ENV vars before running our code.
type AWSConfig ¶ added in v0.2.0
type AWSConfig struct { Profile string `conf:"no-prefix, global-flag, env:AWS_PROFILE, cli:aws-profile, cli-u: aws profile"` Region string `conf:"no-prefix, global-flag, default:us-east-1, env:AWS_REGION, cli:aws-region, cli-u: aws region (default us-east-1)"` }
AWSConfig is a configuration struct using the conf annotated tags which allows you to use it to configure cli systems or lambdas from env or cli inputs
type BuildResult ¶ added in v0.2.0
type BuildResult struct { Settings BuildSettings ZipName string ZipData []byte }
type BuildSettings ¶ added in v0.2.0
type CodeLayout ¶ added in v0.2.0
type CodeLayout struct { Root string Lambdas string CLI string Infra string Build string Terraform string }
func DefaultCodeLayout ¶ added in v0.2.0
func DefaultCodeLayout(root, cliPath string) CodeLayout
func (CodeLayout) BuildDir ¶ added in v0.2.0
func (cl CodeLayout) BuildDir() string
func (CodeLayout) CLIDir ¶ added in v0.2.0
func (cl CodeLayout) CLIDir() string
func (CodeLayout) InfraDir ¶ added in v0.2.0
func (cl CodeLayout) InfraDir() string
func (CodeLayout) LambdasDir ¶ added in v0.2.0
func (cl CodeLayout) LambdasDir() string
func (CodeLayout) RootDir ¶ added in v0.2.0
func (cl CodeLayout) RootDir() string
func (CodeLayout) TerraformDir ¶ added in v0.2.0
func (cl CodeLayout) TerraformDir() string
func (CodeLayout) TriggerDir ¶ added in v0.2.0
func (cl CodeLayout) TriggerDir(et InvokeTrigger) string
type CompileResult ¶ added in v0.2.0
type ConcreteHandlerFn ¶ added in v0.2.0
type ConcreteHandlerFn func() (out interface{}, err error)
type Configurable ¶ added in v0.2.0
type Configurable interface { ProcessEnv() error ProcessCLI(v *viper.Viper) error CollectParamsFromEnv(appTitle string) (map[string]string, error) ParamNames(appTitle string) ([]string, error) EnvNames() ([]string, error) EnvToMap() (map[string]string, error) SetPrefix(prefix string) GetPrefix() IsPrefixEnabled() bool MarkDefaultsAsExcluded() MarkDefaultsAsIncluded() SetExcludeDefaults(value bool) IsDefaultsExcluded() bool }
type Feature ¶ added in v0.2.0
type Feature struct { Name string QualifiedName string Trigger InvokeTrigger BinaryName string BinaryZipName string Conf Configurable Env map[string]string }
func (Feature) NameWithTrigger ¶ added in v0.2.0
func (Feature) TriggerDir ¶ added in v0.2.0
type FeatureDeployment ¶ added in v0.2.0
type GlobalResources ¶ added in v0.2.0
type GlobalResources struct { RemoteState TFResource Repo Repo RootDir string Config map[string]TFResource }
func (GlobalResources) Cognito ¶ added in v0.2.0
func (gr GlobalResources) Cognito() (TFResource, bool)
func (GlobalResources) KeyPair ¶ added in v0.2.0
func (gr GlobalResources) KeyPair() (TFResource, bool)
func (GlobalResources) LambdaDeployBucket ¶ added in v0.2.0
func (gr GlobalResources) LambdaDeployBucket() (TFResource, bool)
func (GlobalResources) Messaging ¶ added in v0.2.0
func (gr GlobalResources) Messaging() (TFResource, bool)
func (GlobalResources) Networking ¶ added in v0.2.0
func (gr GlobalResources) Networking() (TFResource, bool)
type InvokeTrigger ¶ added in v0.2.0
type InvokeTrigger string
func InvokeTriggerFromEvent ¶ added in v0.2.0
func InvokeTriggerFromEvent(t reflect.Type) (InvokeTrigger, error)
func InvokeTriggerFromString ¶ added in v0.2.0
func InvokeTriggerFromString(s string) (InvokeTrigger, error)
func (InvokeTrigger) IsEmpty ¶ added in v0.2.0
func (lt InvokeTrigger) IsEmpty() bool
func (InvokeTrigger) String ¶ added in v0.2.0
func (lt InvokeTrigger) String() string
type MicroService ¶ added in v0.2.0
type MicroService struct { CodeLayout Resource TFResource Account AWSAccount Name ServiceName Repo Repo Features map[string]Feature }
Inputs for microservices
1) root directory - absolute path to the microservice codebase 2) repo - GitHub repository information used to checkout the code base 3) app title - the base name in our AWS resource naming convention for microservices 4) cli title - the name of microservice's cli binary used to manage this cli 5) env - name of the aws environment the microservice will run in 6) region - default aws region when managing aws resources through the sdk 7) profile - the aws profile used by system managing the environment. used for creds
func NewMicroService ¶ added in v0.2.0
func NewMicroService(in MicroServiceIn) (*MicroService, error)
func (*MicroService) AddByTrigger ¶ added in v0.2.0
func (s *MicroService) AddByTrigger(et InvokeTrigger) error
func (*MicroService) AddFeature ¶ added in v0.2.0
func (s *MicroService) AddFeature(et InvokeTrigger, title string) error
func (*MicroService) BuildFeature ¶ added in v0.2.0
func (s *MicroService) BuildFeature(feature Feature, codeDir ...string) (*CompileResult, error)
func (*MicroService) BuildFeatureCode ¶ added in v0.2.0
func (s *MicroService) BuildFeatureCode(buildDir, binaryName, sourceDir string) (*CompileResult, error)
func (*MicroService) Feature ¶ added in v0.2.0
func (s *MicroService) Feature(title string) (Feature, error)
func (*MicroService) GoPath ¶ added in v0.2.0
func (s *MicroService) GoPath() (string, error)
func (*MicroService) LoadFeaturesFromFilesystem ¶ added in v0.2.0
func (s *MicroService) LoadFeaturesFromFilesystem() error
func (*MicroService) NewBuildSettings ¶ added in v0.2.0
func (s *MicroService) NewBuildSettings(feature Feature) BuildSettings
func (*MicroService) String ¶ added in v0.2.0
func (s *MicroService) String() string
func (*MicroService) UpdateEnvWithPStoreCmd ¶ added in v0.2.0
func (s *MicroService) UpdateEnvWithPStoreCmd(feature string) (*exec.Cmd, error)
type MicroServiceIn ¶ added in v0.2.0
type MockTimeout ¶ added in v0.2.0
func (*MockTimeout) WithTimeConstraint ¶ added in v0.2.0
func (m *MockTimeout) WithTimeConstraint(_ context.Context, fn ConcreteHandlerFn) (out interface{}, err error)
type Prefix ¶
Prefix represents our naming prefix, used when creating resources with terraform. Every fender resource has a prefix to encode information about it. The fender prefix is laid out as follows: <region_code>-<env> region_code - this is the aws region code so `use1 [us-east-1]` env - the environment this resource is provisioned in. `[prod,qa,active,<developer_code>]`
func DefaultPrefix ¶ added in v0.2.0
func (Prefix) RegionCode ¶
type RegionConfig ¶ added in v0.2.0
type RegionConfig Region
type ServiceName ¶ added in v0.2.0
ServiceName is used for fender microservices. These are a repository of lambdas and as such the Microservice is not a physical aws resource but rather a collection of resources which include lambdas, apigw, sns queues, dynamodb etc... This name would act as the Prefix for those physical resources
func NewServiceName ¶ added in v0.2.0
func NewServiceName(env string, title string) (ServiceName, error)
func (ServiceName) AppTitle ¶ added in v0.2.0
func (sn ServiceName) AppTitle() string
func (ServiceName) QualifiedName ¶ added in v0.2.0
func (sn ServiceName) QualifiedName() string
func (ServiceName) String ¶ added in v0.2.0
func (sn ServiceName) String() string
type TFBackend ¶ added in v0.2.0
func NewTFBackend ¶ added in v0.2.0
type TFResource ¶ added in v0.2.0
type TFResource struct { Dir string StateFile string PlanFile string Name string Backend TFBackend Vars map[string]string }
func NewTFResource ¶ added in v0.2.0
func NewTFResource(rootDir string, prefix Prefix, label string) TFResource
func (TFResource) IsBackend ¶ added in v0.2.0
func (tr TFResource) IsBackend() bool
type Terraform ¶ added in v0.2.0
type Terraform struct { BinaryDir string BinaryName string Version string GlobalResources GlobalResources }
Terraform stands for Terraform it holds the path to terraform binary as well as the Repo for global resources to be provisioned into the developer local aws account. Dir is where we will clone our global resource's repo.
type Timeout ¶ added in v0.2.0
type Timeout struct {
// contains filtered or unexported fields
}
func NewTimeout ¶ added in v0.2.0
func NewTimeout(config TimeoutConfig) *Timeout
func (*Timeout) WithTimeConstraint ¶ added in v0.2.0
func (t *Timeout) WithTimeConstraint(ctx context.Context, fn ConcreteHandlerFn) (out interface{}, err error)
type TimeoutCapturing ¶ added in v0.2.0
type TimeoutCapturing interface {
WithTimeConstraint(ctx context.Context, fn ConcreteHandlerFn) (out interface{}, err error)
}
type TimeoutConfig ¶ added in v0.2.0
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package cog is responsible for providing an aws cognito client as well as lambda handling front controller pattern for all microservice lambda features that need logging, timeout and panic handling.
|
Package cog is responsible for providing an aws cognito client as well as lambda handling front controller pattern for all microservice lambda features that need logging, timeout and panic handling. |
Package dynamo implements various design patterns for dynamodb and looks to simplify the aws api for aws-sdk-go-v2
|
Package dynamo implements various design patterns for dynamodb and looks to simplify the aws api for aws-sdk-go-v2 |
Package infra is responsible for infrastructure related concerns of the app like deploying and configuration
|
Package infra is responsible for infrastructure related concerns of the app like deploying and configuration |
Package pstore implements a parameter store client used specifically to managing configuration data for microservices
|
Package pstore implements a parameter store client used specifically to managing configuration data for microservices |
Package security is used to create key-pairs and tunnel database connections in the local aws env for development
|
Package security is used to create key-pairs and tunnel database connections in the local aws env for development |