How do I setup AWS SDK credentials and region?

Sparta relies on standard AWS SDK configuration settings. See the official documentation for more information.

During development, configuration is typically done through environment variables:


What flags are defined during AWS AMI compilation?

  • TAGS: -tags lambdabinary

What working directory should I use?

Your working directory should be the root of your Sparta application. Eg, use

go run main.go provision --level info --s3Bucket $S3_BUCKET

rather than

go run ./some/child/path/main.go provision --level info --s3Bucket $S3_BUCKET

See GitHub for more details.

How can I test locally?

Local testing is available via the explore command.

Event Sources - SES

Where does the SpartaRuleSet come from?

SES only permits a single active receipt rule. Additionally, it’s possible that multiple Sparta-based services are handing different SES recipients.

All Sparta-based services share the SpartaRuleSet SES ruleset, and uniquely identify their Rules by including the current servicename as part of the SES ReceiptRule.

Why does provision not always enable the SpartaRuleSet?

Initial SpartaRuleSet will make it the active ruleset, but Sparta assumes that manual updates made outside of the context of the framework were done with good reason and doesn’t attempt to override the user setting.


Where can I view my function’s *logger output?

Each lambda function includes privileges to write to CloudWatch Logs. The *logrus.logger output is written (with a brief delay) to a lambda-specific log group.

The CloudWatch log group name includes a sanitized version of your Go function name & owning service name.

Where can I view Sparta’s golang spawn metrics?

Visit the CloudWatch Metrics AWS console page and select the Sparta/{SERVICE_NAME} namespace:


Sparta publishes two counters:

  • ProcessSpawned: A new Go process was spawned to handle requests
  • ProcessReused: An existing Go process was used to handle requests. See also the discussion on AWS Lambda container reuse.

How can I include additional AWS resources as part of my Sparta application?

Define a TemplateDecorator function and annotate the *gocf.Template with additional AWS resources.

For more flexibility, use a WorkflowHook.

How can I provide environment variables to lambda functions?

Sparta uses conditional compilation rather than environment variables. See Managing Environments for more information.

Does Sparta support Versioning & Aliasing?


Define a TemplateDecorator function and annotate the *gocf.Template with an AutoIncrementingLambdaVersionInfo resource. During each provision operation, the AutoIncrementingLambdaVersionInfo resource will dynamically update the CloudFormation template with a new version.

autoIncrementingInfo, autoIncrementingInfoErr := spartaCF.AddAutoIncrementingLambdaVersionResource(serviceName,

You can also move the “alias pointer” by referencing one or more of the versions available in the returned struct. For example, to set the alias pointer to the most recent version:

// Add an alias to the version we're publishing as part of this `provision` operation
aliasResourceName := sparta.CloudFormationResourceName("Alias", lambdaResourceName)
aliasResource := &gocf.LambdaAlias{
    Name:            gocf.String("MostRecentVersion"),
    FunctionName:    gocf.Ref(lambdaResourceName).String(),
    FunctionVersion: gocf.GetAtt(autoIncrementingInfo.CurrentVersionResourceName, "Version").String(),
cfTemplate.AddResource(aliasResourceName, aliasResource)

How do I forward additional metrics?

Sparta-deployed AWS Lambda functions always operate with CloudWatch Metrics putMetric privileges. Your lambda code can call putMetric with application-specific data.

How do I setup alerts on additional metrics?

Define a TemplateDecorator function and annotate the *gocf.Template with the needed AWS::CloudWatch::Alarm values. Use CloudFormationResourceName(prefix, …parts) to help generate unique resource names.

How can I determine the outputs available in sparta.Discover() for dynamic AWS resources?

The list of registered output provider types is defined by cloudformationTypeMapDiscoveryOutputs in cloudformation_resources.go. See the CloudFormation Resource Types Reference for information on interpreting the values.