github.com/mweagle/Sparta@v1.15.0/execute_build.go (about) 1 // +build !lambdabinary 2 3 package sparta 4 5 import ( 6 gocf "github.com/mweagle/go-cloudformation" 7 "github.com/pkg/errors" 8 "github.com/sirupsen/logrus" 9 ) 10 11 // StampedBuildID is the buildID stamped into the binary. For the case of a 12 // local build this is set by the provision command and the same value 13 // is stamped into the cross compiled binary at AWS Lambda execution time 14 var StampedBuildID string 15 16 // Execute creates an HTTP listener to dispatch execution. Typically 17 // called via Main() via command line arguments. 18 func Execute(serviceName string, 19 lambdaAWSInfos []*LambdaAWSInfo, 20 logger *logrus.Logger) error { 21 // Execute no longer supported in non AWS binaries... 22 return errors.Errorf("Execute not supported outside of AWS Lambda environment") 23 } 24 25 // awsLambdaFunctionName returns the name of the function, which 26 // is set in the CloudFormation template that is published 27 // into the container as `AWS_LAMBDA_FUNCTION_NAME`. The function name 28 // is dependent on the CloudFormation stack name so that 29 // CodePipeline based builds can properly create unique FunctionNAmes 30 // within an account 31 func awsLambdaFunctionName(internalFunctionName string) gocf.Stringable { 32 sanitizedName := awsLambdaInternalName(internalFunctionName) 33 // When we build, we return a gocf.Join that 34 // will use the stack name and the internal name. When we run, we're going 35 // to use the name discovered from the environment. 36 return gocf.Join("", 37 gocf.Ref("AWS::StackName"), 38 gocf.String(functionNameDelimiter), 39 gocf.String(sanitizedName)) 40 }