-
Notifications
You must be signed in to change notification settings - Fork 48
/
sparta_constants.go
125 lines (111 loc) · 3.84 KB
/
sparta_constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package sparta
import (
"fmt"
"strings"
_ "github.com/aws/aws-lambda-go/lambda" // Force dep to resolve
_ "github.com/aws/aws-lambda-go/lambdacontext" // Force dep to resolve
)
////////////////////////////////////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////////////////////////////////////
const (
// ProperName is the DRY name definition
ProperName = "Sparta"
)
const (
// LambdaBinaryTag is the build tag name used when building the binary
LambdaBinaryTag = "lambdabinary"
)
var (
// SpartaVersion defines the current Sparta release
SpartaVersion = fmt.Sprintf("3.0.0.%s", SpartaGitShortHash)
)
// AWSLambdaRuntimeName is an alias for the runtime name
type AWSLambdaRuntimeName string
const (
// Go1LambdaRuntime is the Go version runtime used for the lambda function
Go1LambdaRuntime AWSLambdaRuntimeName = "go1.x"
)
var (
// SpartaBinaryName is binary name that exposes the Go lambda function
SpartaBinaryName = fmt.Sprintf("%s.lambda.amd64", ProperName)
)
const (
// Custom Resource typename used to create new cloudFormationUserDefinedFunctionCustomResource
cloudFormationLambda = "Custom::SpartaLambdaCustomResource"
// divider length is the length of a divider in the text
// based CLI output
dividerLength = 48
)
const (
// envVarLogLevel is the provision time debug value
// carried into the execution environment
envVarLogLevel = "SPARTA_LOG_LEVEL"
// spartaEnvVarFunctionName is the name of this function in the
// map. It's the function that will be registered to run
// envVarFunctionName = "SPARTA_FUNC_NAME"
// envVarDiscoveryInformation is the name of the discovery information
// published into the environment
envVarDiscoveryInformation = "SPARTA_DISCOVERY_INFO"
)
var (
// internal logging header
headerDivider = strings.Repeat("═", dividerLength)
)
// AWS Principal ARNs from http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
// See also
// http://docs.aws.amazon.com/general/latest/gr/rande.html
// for region specific principal names
const (
// @enum AWSPrincipal
APIGatewayPrincipal = "apigateway.amazonaws.com"
// @enum AWSPrincipal
CloudWatchEventsPrincipal = "events.amazonaws.com"
// @enum AWSPrincipal
SESPrincipal = "ses.amazonaws.com"
// @enum AWSPrincipal
SNSPrincipal = "sns.amazonaws.com"
// @enum AWSPrincipal
EC2Principal = "ec2.amazonaws.com"
// @enum AWSPrincipal
LambdaPrincipal = "lambda.amazonaws.com"
// @enum AWSPrincipal
ElasticLoadBalancingPrincipal = "elasticloadbalancing.amazonaws.com"
// @enum KinesisFirehosePrincipal
KinesisFirehosePrincipal = "firehose.amazonaws.com"
// @enum EventBridgePrincipal
EventBridgePrincipal = "events.amazonaws.com"
// @enum StepMachinePrincipal
StepMachinePrincipal = "states.amazonaws.com"
)
type contextKey int
const (
// ContextKeyLogger is the request-independent *zerolog.Logger
// instance common to all requests
ContextKeyLogger contextKey = iota
// ContextKeyRequestLogger is the *zerolog.Logger instance
// that is annotated with request-identifying
// information extracted from the AWS context object
ContextKeyRequestLogger
// ContextKeyLambdaContext is the *sparta.LambdaContext
// pointer in the request
// DEPRECATED
ContextKeyLambdaContext
// ContextKeyLambdaError is the possible error that was returned
// from the lambda function
ContextKeyLambdaError
// ContextKeyLambdaResponse is the possible response that
// was returned from the lambda function
ContextKeyLambdaResponse
// ContextKeyAWSConfig is the aws Session instance for this
// request
ContextKeyAWSConfig
)
const (
// ContextKeyBuildOutputDir is the build-time output location
ContextKeyBuildOutputDir contextKey = iota
// ContextKeyBuildID is the build-time build id
ContextKeyBuildID
// ContextKeyBuildBinaryName is the name of the binary we're building
ContextKeyBuildBinaryName
)