• Stars
    star
    719
  • Rank 62,985 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

go microservices, powered by AWS Lambda

EOL

Times have changed since I started this work. I no longer have the resources to adequately maintain this project. Additionally, there now also exist several other options, including SAM, around which lively communities have formed. With v3, all CloudFormation API changes have been migrated to go-formation and all AWS API SDK calls moved to AWS v2. This likely marks the end of my active development on Sparta.

If this project has been helpful to you and you're interested in becoming a shepherd, please open an issue. Thanks all for your feedback, support, and recommendations over the years.

Keep on serverlessing!

  • Matt December 5th, 2021

Sparta v3

This is v3 of Sparta which is not backward compatible with v1 or v2 versions.

Sparta

Build Status

GoDoc

Go Report Card

Visit gosparta.io for complete documentation.

Version Info

This is the breaking v2 version of Sparta. The previous version is available at at the /v1 branch.

Overview

Sparta takes a set of golang functions and automatically provisions them in AWS Lambda as a logical unit.

AWS Lambda functions are defined using the standard AWS Lambda signatures:

  • func()
  • func() error
  • func(TIn) error
  • func() (TOut, error)
  • func(context.Context) error
  • func(context.Context, TIn) error
  • func(context.Context) (TOut, error)
  • func(context.Context, TIn) (TOut, error)

The TIn and TOut parameters represent encoding/json un/marshallable types.

For instance:

// Standard AWS λ function
func helloWorld(ctx context.Context) (string, error) {
  ...
}

where

  • ctx : The request context that includes both the AWS Context as well as Sparta specific values

Consumers define a set of lambda functions and provide them to Sparta to create a self-documenting, self-deploying AWS Lambda binary:

  lambdaFn, _ := sparta.NewAWSLambda("Hello World",
    helloWorld,
    sparta.IAMRoleDefinition{})

  var lambdaFunctions []*sparta.LambdaAWSInfo
  lambdaFunctions = append(lambdaFunctions, lambdaFn)

  err := sparta.Main("HelloWorldStack",
    "My Hello World stack",
    lambdaFunctions,
    nil,
    nil)

Visit gosparta.io for complete documentation.

Contributing

Sparta contributions are most welcome. Please consult the latest issues for open issues.

Building

Locally building or testing Sparta itself is typically only needed to make package changes. Sparta is more often used as a required import of another application. Building is done via mage.

To get started building and verifying local changes:

  1. go get -u -d github.com/magefile/mage
  2. In the .../mweagle/Sparta directory, run mage -l to list the current targets:
\$ mage -l
Targets:
  build                         the application
  ciBuild                       is the task to build in the context of CI pipeline
  clean                         the working directory
  compareAgainstMasterBranch    is a convenience function to show the comparisons of the current pushed branch against the master branch
  describe                      runs the `TestDescribe` test to generate a describe HTML output file at graph.html
  docsBuild                     builds the public documentation site in the /docs folder
  docsCommit                    builds and commits the current documentation with an autogenerated comment
  docsEdit                      starts a Hugo server and hot reloads the documentation at http://localhost:1313
  docsInstallRequirements       installs the required Hugo version
  ensureAllPreconditions        ensures that the source passes *ALL* static `ensure*` precondition steps
  ensureCIBuildEnvironment      is the command that sets up the CI environment to run the build.
  ensureCleanTree               ensures that the git tree is clean
  ensureFormatted               ensures that the source code is formatted with goimports
  ensureGoFmt                   ensures that the source is `gofmt -s` is empty
  ensureLint                    ensures that the source is `golint`ed
  ensureMarkdownSpelling        ensures that all *.MD files are checked for common spelling mistakes
  ensurePrealloc                ensures that slices that could be preallocated are enforced
  ensureSpelling                ensures that there are no misspellings in the source
  ensureStaticChecks            ensures that the source code passes static code checks
  ensureVet                     ensures that the source has been `go vet`ted
  fetchCloudFormationSchema     we have the latest CloudFormation schema as part of generating constants.
  generateAutomaticCode         is the handler that runs the codegen part of things
  generateBuildInfo             creates the automatic buildinfo.go file so that we can stamp the SHA into the binaries we build...
  generateConstants             runs the set of commands that update the embedded CONSTANTS for both local and AWS Lambda execution
  logCodeMetrics                ensures that the source code is formatted with goimports
  publish                       the latest source
  test                          runs the Sparta tests
  testCover                     runs the test and opens up the resulting report
  unitTest                      only runs the unit tests

Confirm tests are passing on HEAD by first running mage -v test.

As you periodically make local changes, run mage -v test to confirm backward compatibility.

Tests

When possible, please include a test case that verifies the local change and ensures compatibility.

Contributors

Thanks to all Sparta contributors (alphabetical):

More Repositories

1

phi-accrual-detector

phi-accrual-detector
JavaScript
36
star
2

circuit-breaker

Port of Akka's CircuitBreaker pattern to Node.js
JavaScript
33
star
3

Logpig

Logback appender that forwards rolled logfiles to S3 & sample Pig script for analysis
Java
13
star
4

ssm-cache

SSM Parameter Store cache library
Go
10
star
5

C4-PlantUML-Themes

C4-PlantUML-Themes autogenerated from ColorBrewer and Seaborn palettes
Python
7
star
6

SpartaHTML

Sparta application that demonstrates provisioning an S3 backed site with a CORS-enabled API Gateway
CSS
5
star
7

SpartaVault

Part of the Sparta family - use AWS KMS to encrypt secrets to Go variables
Go
5
star
8

iOS-Backup-Bookmark-Exporter

Transforms the iOS SQLite bookmarks.db file to an HTML file that can be imported into Safari
5
star
9

SpartaPProf

Sample Sparta application showing how to use pprof to profile AWS Lambda code
Go
2
star
10

Tereus

JavaScript
2
star
11

SpartaOmega

Sparta application that demonstrates calling same code from AWS Lambda or EC2 instance
Go
2
star
12

SpartaHoneycomb

Sample Sparta application redirecting logs to Honeycomb.io
Go
2
star
13

go-cloudcondenser

Library to produce CloudFormation templates from Go code
Go
2
star
14

SpartaCodePipeline

Sparta app with CodePipeline/CodeBuild/CloudFormation CI/CD pipeline
Go
2
star
15

SpartaSafeDeploy

Sparta application that demonstrates how to do gradual Lambda deployments
Go
1
star
16

SpartaHTMLAuth

Sparta HTML site with custom Lambda authorizer
CSS
1
star
17

SpartaALB

Sample Sparta application that shows how to expose Lambda functions via Application Load Balancer
Go
1
star
18

Wiki

Test wiki
1
star
19

SpartaGeekwire

GeekWire cloud summit sample app
JavaScript
1
star
20

Chiller

Apache Karaf Quickstarter
Java
1
star
21

SpartaHugo

Deploy a Hugo-powered static site with Sparta-backed AWS Lambda functions
HTML
1
star
22

goestimate

Run Monte Carlo simulations defined in JSON and produce critical path SVG image results
Go
1
star