Sparta shield

A Go framework for AWS Lambda microservices

Features

Unified Language

Use a single Go codebase to define your microservice's:

  • Application logic
  • AWS infrastructure
  • Operational metrics
  • Alert conditions
  • Security policies

Complete AWS Ecosystem

Sparta enables your lambda-based service to seamlessly integrate with the entire set of AWS lambda event sources such as:

  • DynamoDB
  • S3
  • Kinesis
  • SNS
  • SES
  • CloudWatch Events
  • CloudWatch Logs
Additionally, your service may provision any other CloudFormation supported resource and even your own CustomResources.

Security

Define IAM Roles with limited privileges to minimize your service’s attack surface. Both string literal and ARN expressions are supported in order to reference dynamically created resources. Sparta treats POLP and #SecOps as first-class goals.

Discovery

A service may provision dynamic AWS infrastructure, and discover, at lambda execution time, the dependent resources’ AWS-assigned outputs (Ref & Fn::Att). Eliminate hardcoded Magic ARNs from your codebase and move towards immutable infrastructure

API Gateway

Make your service HTTPS accessible by binding it to an API Gateway REST API during provisioning. As part of API Gateway creation, Sparta includes API Gateway Mapping Templates with all request data, including user-defined whitelisted parameters, so that you can focus on your core application logic.

Static Sites

Include a CORS-enabled S3-backed site with your service. S3-backed sites include API Gateway discovery information for turnkey deployment.


Sparta Overview]

Sparta exclusively relies on CloudFormation to deploy and update your application. For resources that CloudFormation does not yet support, it uses Lambda-backed Custom Resources so that all service updates support both update and rollback semantics. Sparta’s automatically generated CloudFormation resources use content-based logical IDs whenever possible to preserve service availability during updates.

Hello Lambda World

// File: application.go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"

	"github.com/Sirupsen/logrus"
	sparta "github.com/mweagle/Sparta"
)

////////////////////////////////////////////////////////////////////////////////
// Hello world event handler
//
func helloWorld(event *json.RawMessage,
              	context *sparta.LambdaContext,
              	w http.ResponseWriter,
              	logger *logrus.Logger) {
	logger.Info("Hello World: ", string(*event))
	fmt.Fprint(w, string(*event))
}

////////////////////////////////////////////////////////////////////////////////
// Main
func main() {
  var lambdaFunctions []*sparta.LambdaAWSInfo
  lambdaFn := sparta.NewLambda(sparta.IAMRoleDefinition{}, helloWorld, nil)
  lambdaFunctions = append(lambdaFunctions, lambdaFn)

  // Deploy it
  sparta.Main("SpartaHelloWorld",
		"Simple Sparta application that creates a single AWS Lambda function",
		lambdaFunctions,
                nil,
                nil)
}

Getting Started

To get started using Sparta, begin with the Documentation.

Administration

Questions?

Get in touch via:

Other resources