Documentation ¶
Index ¶
- Variables
- func Contains(s []string, v string) bool
- func CreateLambdaNetwork()
- func GetFuncName(resourceName, functionName string) string
- func GetList(projectPath, wish string) []string
- func GetWorkingDir() string
- func LoadTemplateFromBox(b *packr.Box, file string) *template.Template
- func RemoveFiles(pPath, aName, fName string)
- func RunCmd(name string, args ...string)
- func RunCmdWithEnv(envs []string, name string, args ...string)
- func StartLocalDynamoDB()
- type ALBEvent
- type AlexaEvent
- type Attribute
- type AttributeDef
- type AttributeDefinition
- type Authorizer
- type CognitoEvent
- type CustomDomainConfig
- type DeploymentBucket
- type DomainConfig
- type Events
- type FnEnvironment
- type Function
- type GlobalConfig
- type GlobalIndex
- type HTTPEvent
- type IOTEvent
- type KeySchema
- type Layer
- type LocalIndex
- type LogConfig
- type MUGConfig
- func (m MUGConfig) CreateResourceTables(list []string, mode string, overwrite bool)
- func (m MUGConfig) MakeBuild(list []string, test bool)
- func (m MUGConfig) MakeDebug(list []string)
- func (m MUGConfig) NewServerlessConfig(resource string) ServerlessConfig
- func (m MUGConfig) ReadServerlessConfig(rn string) ServerlessConfig
- func (m *MUGConfig) RemoveResource(rN string)
- func (m MUGConfig) Write()
- type Model
- type NewResource
- type Package
- type Projection
- type Properties
- type Provider
- type ProvisionedThroughput
- type Reference
- type ResourceDefinition
- type Resources
- type RoleStatement
- type S3Event
- type SAMEvent
- type SAMFnProp
- type SAMFunction
- type SAMProp
- type SNSEvent
- type SQSEvent
- type ScheduleEvent
- type ServerlessConfig
- func (s *ServerlessConfig) AddAuth(excludes string)
- func (s *ServerlessConfig) AddFunction(fn *Function)
- func (s *ServerlessConfig) AddPoolEnv(mc MUGConfig, rName, pool string)
- func (s *ServerlessConfig) RemoveAuth()
- func (s *ServerlessConfig) RemoveFunction(n string)
- func (s *ServerlessConfig) SetFunctions(fns []*Function)
- func (s *ServerlessConfig) SetResourceWithModel(r *NewResource, m Model, projectName string)
- func (s *ServerlessConfig) Write(projectPath, mn string)
- type ServerlessFunction
- type Service
- type StreamEvent
- type TTLSpecification
- type TemplateConfig
- type TracingConfig
- type WebSocketEvent
Constants ¶
This section is empty.
Variables ¶
var ( // ResourceBox is the packr box containing the resource file templates ResourceBox = packr.New("resource", "../../templates/resource") // FunctionBox is the packr box containing the function file templates FunctionBox = packr.New("function", "../../templates/function") // MakeBox is the packr box containing the Makefile template MakeBox = packr.New("make", "../../templates/make") )
Functions ¶
func CreateLambdaNetwork ¶
func CreateLambdaNetwork()
CreateLambdaNetwork spins up a lambda network for dynamodb and AWS SAM to interact with one another
func GetFuncName ¶
GetFuncName returns the generated function name for a given resource/ function group name and a functionName
func GetWorkingDir ¶
func GetWorkingDir() string
GetWorkingDir get the directory the current command is run out of
func LoadTemplateFromBox ¶
LoadTemplateFromBox loads a *text/template.Template from a packr.Box
func RunCmdWithEnv ¶
RunCmdWithEnv will run an OS command with the given arguments and an environment
func StartLocalDynamoDB ¶
func StartLocalDynamoDB()
StartLocalDynamoDB spins up the dynamodb-local docker image
Types ¶
type ALBEvent ¶
type ALBEvent struct { ListenerARN string `yaml:"listenerArn"` Priority int `yaml:",omitempty"` Conditions map[string]string `yaml:",omitempty"` }
ALBEvent ...
type AlexaEvent ¶
AlexaEvent ...
type Attribute ¶
type Attribute struct { Name string `json:"name"` Ident flect.Ident `json:"ident"` GoType string `json:"go_type"` AwsType string `json:"aws_type"` }
Attribute represents a resource model's attribute
type AttributeDef ¶
type AttributeDef struct { AttributeName string `yaml:"AttributeName"` AttributeType string `yaml:"AttributeType"` }
AttributeDef ...
type AttributeDefinition ¶
type AttributeDefinition struct { Ident flect.Ident `json:"ident"` AwsType string `json:"aws_type"` }
AttributeDefinition represents the definition of a resource's attribute
type Authorizer ¶
type Authorizer struct { ARN string Name string `yaml:",omitempty"` ResultTTL int `yaml:"resultTtlInSeconds,omitempty"` IdentitySource string `yaml:"identitySource,omitempty"` IdentityValidationExpression string `yaml:"identityValidationExpression,omitempty"` Type string `yaml:",omitempty"` }
Authorizer ...
type CognitoEvent ¶
CognitoEvent ...
type CustomDomainConfig ¶
type CustomDomainConfig struct { BasePath string `yaml:"basePath"` DomanName string `yaml:"domainName"` Stage string CreateRoute53Record bool `yaml:"createRoute53Record"` }
CustomDomainConfig ...
type DeploymentBucket ¶
type DeploymentBucket struct { Name string SSE string `yaml:"serverSideEncryption,omitempty"` Tags map[string]string `yaml:",omitempty"` }
DeploymentBucket ...
type DomainConfig ¶
type DomainConfig struct { Stage string Domains map[string]string `yaml:",omitempty"` CustomDomain CustomDomainConfig `yaml:"customDoman"` }
DomainConfig ...
type Events ¶
type Events struct { HTTP *HTTPEvent `yaml:"http,omitempty"` WebSocket *WebSocketEvent `yaml:"websocket,omitempty"` S3 *S3Event `yaml:"s3,omitempty"` Schedule *ScheduleEvent `yaml:"schedule,omitempty"` SNS *SNSEvent `yaml:"sns,omitempty"` SQS *SQSEvent `yaml:"sqs,omitempty"` Stream *StreamEvent `yaml:"stream,omitempty"` AlexaSkill *AlexaEvent `yaml:"alexaSkill,omitempty"` AlexaSmartHome *AlexaEvent `yaml:"alexaSmartHome,omitempty"` IOT *IOTEvent `yaml:"iot,omitempty"` CognitoUserPool *CognitoEvent `yaml:"cognitoUserPool,omitempty"` ALB *ALBEvent `yaml:"alb,omitempty"` }
Events ...
type FnEnvironment ¶
FnEnvironment ...
type Function ¶
type Function struct { Name string `json:"name"` Handler string `json:"handler"` Path string `json:"path"` Method string `json:"method"` Authentication bool `json:"authentication"` }
Function represents a Function
type GlobalConfig ¶
type GlobalConfig struct {
Function SAMFnProp `yaml:"Function"`
}
GlobalConfig ...
type GlobalIndex ¶
type GlobalIndex struct { IndexName string `yaml:"IndexName"` KeySchema []KeySchema `yaml:"KeySchema"` Projection Projection `yaml:"Projection"` ProvisionedThroughput *ProvisionedThroughput `yaml:"ProvisionedTroughput,omitempty"` }
GlobalIndex ...
type HTTPEvent ¶
type HTTPEvent struct { Path string Method string CORS bool `yaml:",omitempty"` Private bool `yaml:",omitempty"` Authorizer *Authorizer `yaml:",omitempty"` Scopes []string `yaml:",omitempty"` }
HTTPEvent ...
type IOTEvent ¶
type IOTEvent struct { Name string `yaml:",omitempty"` Description string `yaml:",omitempty"` Enabled bool `yaml:",omitempty"` SQL string `yaml:"sql,omitempty"` SQLVersion string `yaml:"sqlVersion,omitempty"` }
IOTEvent ...
type KeySchema ¶
type KeySchema struct { AttributeName string `yaml:"AttributeName"` KeyType string `yaml:"KeyType"` }
KeySchema ...
type Layer ¶
type Layer struct { Path string Name string `yaml:",omitempty"` Description string `yaml:",omitempty"` CompatibleRuntimes []string `yaml:"compatibleRuntimes,omitempty"` License string `yaml:"licenseInfo,omitempty"` AllowedAccounts []string `yaml:"allowedAccounts,omitempty"` Retain bool `yaml:",omitempty"` }
Layer ...
type LocalIndex ¶
type LocalIndex struct { IndexName string `yaml:"IndexName"` KeySchema []KeySchema `yaml:"KeySchema"` Projection Projection `yaml:"Projection"` }
LocalIndex ...
type LogConfig ¶
type LogConfig struct { RESTAPI bool `yaml:"restApi,omitempty"` WebSocket bool `yaml:"websocket,omitempty"` }
LogConfig ...
type MUGConfig ¶
type MUGConfig struct { ProjectName string ProjectPath string ImportPath string Region string Resources map[string]*NewResource }
MUGConfig ...
func (MUGConfig) CreateResourceTables ¶
CreateResourceTables creates the tables in the local DynamoDB named by the given mode
func (MUGConfig) NewServerlessConfig ¶
func (m MUGConfig) NewServerlessConfig(resource string) ServerlessConfig
NewServerlessConfig return a new ServerlessConfig with the attributes from the MUGConfig NewFromResourceConfig returns a ServerlessConfig from a provided ResourceConfig
func (MUGConfig) ReadServerlessConfig ¶
func (m MUGConfig) ReadServerlessConfig(rn string) ServerlessConfig
ReadServerlessConfig reads the ServerlessConfig from serverless.yml in the resource or function group directory. If a serverless.yml file does not exist, a new default ServerlessConfig is returned
func (*MUGConfig) RemoveResource ¶
RemoveResource removes a given resource from the MUGConfig and ServerlessConfig
type Model ¶
type Model struct { Name string `json:"name"` Type string `json:"type"` Ident flect.Ident `json:"ident"` Attributes map[string]Attribute `json:"attributes"` Nested []Model `json:"nested"` Imports []string `json:"imports"` KeySchema map[string]string `json:"key_schema"` GeneratedID bool `json:"generated_id"` CompositeKey bool `json:"composite_key"` BillingMode string `json:"billing_mode"` CapacityUnits map[string]int64 `json:"capacity_units"` }
Model represents a resource model object
func (Model) GetConfigs ¶
func (m Model) GetConfigs() (MUGConfig, ServerlessConfig)
GetConfigs returns the MUGConfig and ServerlessConfig for this Model
func (*Model) GetImports ¶
GetImports recursively iterates through all import slices and adds the import to the root model
type NewResource ¶
type NewResource struct { Ident flect.Ident Attributes map[string]AttributeDefinition }
NewResource ...
type Package ¶
type Package struct { Excludes []string `yaml:"exclude,omitempty"` Includes []string `yaml:"include,omitempty"` Individually bool `yaml:",omitempty"` }
Package ...
type Projection ¶
type Projection struct { NonKeyAttributes []string `yaml:"NonKeyAttributes,omitempty"` ProjectionType string `yaml:"ProjectionType,omitempty"` }
Projection ...
type Properties ¶
type Properties struct { // Properties for Resources AttributeDefinitions []AttributeDef `yaml:"AttributeDefinitions,omitempty"` KeySchema []KeySchema `yaml:"KeySchema,omitempty"` ProvisionedThroughput *ProvisionedThroughput `yaml:"ProvisionedThroughput,omitempty"` BillingMode string `yaml:"BillingMode,omitempty"` TableName string `yaml:"TableName,omitempty"` LocalSecondaryIndexes []LocalIndex `yaml:"LocalSecondaryIndexes,omitempty"` GlobalSecondaryIndexes []GlobalIndex `yaml:"GlobalSecondaryIndexes,omitempty"` TTLSpecification TTLSpecification `yaml:"TimeToLiveSpecification,omitempty"` //Properties for Authorizer Name string `yaml:"Name,omitempty"` IdentitySource string `yaml:"IdentitySource,omitempty"` RestAPIID Reference `yaml:"RestApiId,omitempty"` Type string `yaml:"Type,omitempty"` ProviderARNs []string `yaml:"ProviderARNs,omitempty"` }
Properties ...
type Provider ¶
type Provider struct { Name string Runtime string Region string Stage string StackName string `yaml:"stackName,omitempty"` APIName string `yaml:"apiName,omitempty"` Profile string `yaml:",omitempty"` MemSize string `yaml:"memorySize,omitempty"` ReservedConcurrency int `yaml:"reservedConcurrency,omitempty"` Timeout int `yaml:"timeout,omitempty"` DeyploymentBucket DeploymentBucket `yaml:"deploymendBucket,omitempty"` DeploymentPrefix string `yaml:"deploymentPrefix,omitempty"` Environments map[string]string `yaml:"environment,omitempty"` RoleStatements []RoleStatement `yaml:"iamRoleStatements"` EndpointType string `yaml:"endpointType,omitempty"` NotificationARNs []string `yaml:"notificationArns,omitempty"` Tags map[string]string `yaml:",omitempty"` Tracing TracingConfig `yaml:",omitempty"` Logs LogConfig `yaml:",omitempty"` // contains filtered or unexported fields }
Provider ...
type ProvisionedThroughput ¶
type ProvisionedThroughput struct { ReadCapacityUnits int64 `yaml:"ReadCapacityUnits"` WriteCapacityUnits int64 `yaml:"WriteCapacityUnits"` }
ProvisionedThroughput ...
type ResourceDefinition ¶
type ResourceDefinition struct { DependsOn []string `yaml:"DependsOn,omitempty"` Type string `yaml:"Type"` DeletionPolicy string `yaml:"DeletionPolicy,omitempty"` Properties Properties `yaml:"Properties"` }
ResourceDefinition ...
type Resources ¶
type Resources struct {
Resources map[string]*ResourceDefinition `yaml:"Resources"`
}
Resources ...
type RoleStatement ¶
type RoleStatement struct { Effect string `yaml:"Effect"` Actions []string `yaml:"Action"` Resource string `yaml:"Resource"` }
RoleStatement ...
type SAMFnProp ¶
type SAMFnProp struct { Runtime string `yaml:"Runtime,omitempty"` Handler string `yaml:"Handler,omitempty"` CodeURI string `yaml:"CodeUri,omitempty"` Events map[string]SAMEvent `yaml:"Events,omitempty"` Environment FnEnvironment `yaml:"Environment,omitempty"` }
SAMFnProp ...
type SAMFunction ¶
SAMFunction ...
type SNSEvent ¶
type SNSEvent struct { TopicName string `yaml:"topicName"` DisplayName string `yaml:"displayName,omitempty"` }
SNSEvent ...
type ScheduleEvent ¶
type ScheduleEvent struct { Name string Description string `yaml:",omitempty"` Rate string Enabled bool `yaml:",omitempty"` InputPath string `yaml:"inputPath,omitempty"` }
ScheduleEvent ...
type ServerlessConfig ¶
type ServerlessConfig struct { ProjectPath string `yaml:"-"` Service Service Provider Provider Package Package Functions map[string]*ServerlessFunction `yaml:",omitempty"` Layers map[string]Layer `yaml:",omitempty"` Resources Resources `yaml:",omitempty"` Plugins []string `yaml:",omitempty"` Custom DomainConfig `yaml:",omitempty"` }
ServerlessConfig ...
func NewDefaultServerlessConfig ¶
func NewDefaultServerlessConfig() ServerlessConfig
NewDefaultServerlessConfig return a default ServerlessConfig object
func (*ServerlessConfig) AddAuth ¶
func (s *ServerlessConfig) AddAuth(excludes string)
AddAuth adds Authorization to the ServerlessConfig
func (*ServerlessConfig) AddFunction ¶
func (s *ServerlessConfig) AddFunction(fn *Function)
AddFunction adds a function to the ServerlessConfig
func (*ServerlessConfig) AddPoolEnv ¶
func (s *ServerlessConfig) AddPoolEnv(mc MUGConfig, rName, pool string)
AddPoolEnv adds the given cognito user pool arn as environment in .env
func (*ServerlessConfig) RemoveAuth ¶
func (s *ServerlessConfig) RemoveAuth()
RemoveAuth removes Authorization from the ServerlessConfig
func (*ServerlessConfig) RemoveFunction ¶
func (s *ServerlessConfig) RemoveFunction(n string)
RemoveFunction removes a function from the ServerlessConfig
func (*ServerlessConfig) SetFunctions ¶
func (s *ServerlessConfig) SetFunctions(fns []*Function)
SetFunctions sets a slice of Functions to the ServerlessConfig
func (*ServerlessConfig) SetResourceWithModel ¶
func (s *ServerlessConfig) SetResourceWithModel(r *NewResource, m Model, projectName string)
SetResourceWithModel sets a Resource to the ServerlessConfig
func (*ServerlessConfig) Write ¶
func (s *ServerlessConfig) Write(projectPath, mn string)
Write writes the ServerlessConfig to serverless.yml for the given project path and model name
type ServerlessFunction ¶
type ServerlessFunction struct { Handler string Package Package `yaml:",omitempty"` Name string `yaml:",omitempty"` Description string `yaml:",omitempty"` MemorySize int `yaml:",omitempty"` ReservedConcurrency int `yaml:"reservedConcurrency,omitempty"` RunTime string `yaml:"runtime,omitempty"` Timeout int `yaml:",omitempty"` AWSKMSKeyARN string `yaml:"awsKmsKeyArn,omitempty"` Environments map[string]string `yaml:"environment,omitempty"` Tags map[string]string `yaml:",omitempty"` Layers []string `yaml:",omitempty"` Events []Events }
ServerlessFunction ...
type StreamEvent ¶
type StreamEvent struct { ARN string `yaml:"arn"` BatchSize int `yaml:"batchSize,omitempty"` StartingPosition string `yaml:"startingPosition,omitempty"` Enabled bool `yaml:",omitempty"` }
StreamEvent ...
type TTLSpecification ¶
type TTLSpecification struct { AttributeName string `yaml:"AttributeName"` Enabled bool `yaml:"Enabled"` }
TTLSpecification ...
type TemplateConfig ¶
type TemplateConfig struct { Transform string `yaml:"Transform"` Globals GlobalConfig `yaml:"Globals"` Resources map[string]SAMFunction `yaml:"Resources"` }
TemplateConfig ...
func (*TemplateConfig) AddFunctionsFromServerlessConfig ¶
func (t *TemplateConfig) AddFunctionsFromServerlessConfig(s ServerlessConfig, r string)
AddFunctionsFromServerlessConfig adds the functions from the given ServerlessConfig and resource/ function group
func (*TemplateConfig) Write ¶
func (t *TemplateConfig) Write(projectPath string)
Write writes the TemplateConfig to template.yml
type TracingConfig ¶
type TracingConfig struct { APIGateway bool `yaml:"apiGateway,omitempty"` Lambda bool `yaml:",omitempty"` }
TracingConfig ...
type WebSocketEvent ¶
type WebSocketEvent struct { Route string Authorizer *Authorizer `yaml:",omitempty"` }
WebSocketEvent ...