This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create an http.Request object with this data... | |
spartaResp := newSpartaMockHTTPResponse() | |
spartaReq := &http.Request{ | |
Method: "POST", | |
URL: &url.URL{ | |
Scheme: "http", | |
Path: fmt.Sprintf("/%s", functionName), | |
}, | |
Proto: "HTTP/1.1", | |
ProtoMajor: 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bytesWritten = lib.Lambda(funcName.encode(‘utf-8’), | |
json.dumps(request).encode(‘utf-8’), | |
credentials.access_key.encode(‘utf-8’), | |
credentials.secret_key.encode(‘utf-8’), | |
credentials.token.encode(‘utf-8’), | |
byref(exitCode), | |
response_content_type_buffer, | |
MAX_RESPONSE_CONTENT_TYPE_SIZE-1, | |
response_buffer, | |
MAX_RESPONSE_SIZE-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// #include <stdio.h> | |
// #include <stdlib.h> | |
// #include <string.h> | |
// #include <stdio.h> | |
import "C" | |
import "github.com/aws/aws-sdk-go/aws/credentials" | |
import ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
sparta "github.com/mweagle/Sparta" | |
"github.com/mweagle/SpartaPython" | |
"github.com/mweagle/Sparta/cgo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Standard AWS λ function | |
func helloWorld(event *json.RawMessage, | |
context *sparta.LambdaContext, | |
w http.ResponseWriter, | |
logger *logrus.Logger) { | |
helloWorldCounterMetric.Inc(1) | |
fmt.Fprint(w, "Hello World") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Go get the outputs of the GrafanaStack | |
awsSession := session.New() | |
cloudFormationSvc := cloudformation.New(awsSession) | |
params := &cloudformation.DescribeStacksInput{ | |
StackName: aws.String(GrafanaStackName), | |
} | |
outputResults, outputResultsErr := cloudFormationSvc.DescribeStacks(params) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lambdaFn.Decorator = func(serviceName string, | |
lambdaResourceName string, | |
lambdaResource gocf.LambdaFunction, | |
resourceMetadata map[string]interface{}, | |
S3Bucket string, | |
S3Key string, | |
buildID string, | |
template *gocf.Template, | |
context map[string]interface{}, | |
logger *logrus.Logger) error { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Environment: &gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironmentList{ | |
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{ | |
Name: gocf.String("AWS_REGION"), | |
Value: gocf.Ref("AWS::Region").String(), | |
}, | |
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{ | |
Name: gocf.String(sqsQueueURLEnvVar), | |
Value: gocf.Ref(sqsResourceName).String(), | |
}, | |
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ec2IAMStatements = append(ec2IAMStatements, spartaIAM.PolicyStatement{ | |
Action: []string{"sqs:ChangeMessageVisibility", | |
"sqs:DeleteMessage", | |
"sqs:GetQueueAttributes", | |
"sqs:ReceiveMessage"}, | |
Effect: "Allow", | |
Resource: gocf.GetAtt(sqsResourceName, "Arn").String(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setup an IAM role that allows the lambda function to send a message | |
// to the queue. | |
iamPolicy := sparta.IAMRoleDefinition{ | |
Privileges: []sparta.IAMRolePrivilege{ | |
sparta.IAMRolePrivilege{ | |
Actions: []string{ | |
"sqs:SendMessage"}, | |
Resource: gocf.GetAtt(sqsResourceName, "Arn").String(), | |
}, | |
}, |