Skip to content

Commit

Permalink
Merge pull request #114 from mweagle/mweagle/1.2.1
Browse files Browse the repository at this point in the history
Sparta 1.2.1
  • Loading branch information
mweagle committed Aug 12, 2018
2 parents d0b19f2 + 472b42d commit 2231370
Show file tree
Hide file tree
Showing 20 changed files with 382 additions and 46 deletions.
18 changes: 18 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Change Notes

## v1.2.1

- :warning: **BREAKING**
- :checkered_flag: **CHANGES**
- Added `decorator.LogAggregatorDecorator`
- This is a decorator that:
1. Creates a [CloudWatchLogs Subscription Filter](https://t.co/C0cbo99Tsr) for the Lambda functions
1. Creates a Kinesis sink with the user defined shard count to receive the log events.
1. Subscribes the relay lambda function to the Kinesis stream
1. See [SpartaPProf](https://github.com/mweagle/SpartaPProf) for an example that relays log entries to Google StackDriver.
- Added `decorator.PublishAttOutputDecorator` and `decorator.PublishRefOutputDecorator` as convenience functions to update the Stack [Outputs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html) section.
- Added `RuntimeLoggerHook` to [WorkflowHooks](https://godoc.org/github.com/mweagle/Sparta#WorkflowHooks) to support logrus logger [hooks](https://github.com/sirupsen/logrus#hooks).
- Added `IsExecutingInLambda () bool` to return execution environment
- :bug: **FIXED**
- [`$GOPATH` is no longer present by default](https://github.com/mweagle/Sparta/issues/111)
- [`gas` was replaced by `gosec`](https://github.com/mweagle/Sparta/issues/112)
- [`tview.ANSIIWriter` has been renamed to `tview.ANSIWriter`](https://github.com/mweagle/Sparta/issues/110)

## v1.2

- :warning: **BREAKING**
Expand Down
29 changes: 15 additions & 14 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@

[[constraint]]
name = "github.com/aws/aws-lambda-go"
version = "1.1.0"
version = "1.4.0"

[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "1.13.38"
version = "1.15.8"

[[constraint]]
name = "github.com/briandowns/spinner"
version = "1.0.0"
version = "1.1"

[[constraint]]
branch = "master"
Expand Down Expand Up @@ -75,7 +75,7 @@

[[constraint]]
name = "gopkg.in/go-playground/validator.v9"
version = "9.15.0"
version = "9.20.2"

[prune]
go-tests = true
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
.DEFAULT_GOAL=build

GOPATH?=$HOME/go
$(info $$GOPATH is [${GOPATH}])

GO_LINT_PATH := $(GOPATH)/bin/golint
GAS_PATH := $(GOPATH)/bin/gas
GAS_PATH := $(GOPATH)/bin/gosec
WORK_DIR := ./sparta
GO_GET_FLAGS := -u

Expand Down Expand Up @@ -37,7 +40,7 @@ go_get_requirements:
go get $(GO_GET_FLAGS) github.com/fzipp/gocyclo
go get $(GO_GET_FLAGS) github.com/golang/lint/golint
go get $(GO_GET_FLAGS) github.com/mjibson/esc
go get $(GO_GET_FLAGS) github.com/GoASTScanner/gas/cmd/gas/...
go get $(GO_GET_FLAGS) github.com/securego/gosec/cmd/gosec/...

.PHONY: update_requirements
update_requirements: GO_GET_FLAGS=-u
Expand Down Expand Up @@ -72,7 +75,7 @@ fmtcheck:install_requirements
.PHONY: validate
validate: install_requirements vet lint fmtcheck
megacheck -ignore github.com/mweagle/Sparta/CONSTANTS.go:*
$(GAS_PATH) -exclude=G204 ./...
$(GAS_PATH) -exclude=G204,G505,G401 ./...

docs:
@echo ""
Expand Down
19 changes: 12 additions & 7 deletions aws/cloudformation/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,24 @@ func parseFnJoinExpr(data map[string]interface{}) (*gocf.StringExpr, error) {
}

func stackCapabilities(template *gocf.Template) []*string {
capabilitiesMap := make(map[string]bool, 0)

// Only require IAM capability if the definition requires it.
capabilities := make([]*string, 0)
for _, eachResource := range template.Resources {
if eachResource.Properties.CfnResourceType() == "AWS::IAM::Role" {
found := false
for _, eachElement := range capabilities {
found = (found || (*eachElement == "CAPABILITY_IAM"))
}
if !found {
capabilities = append(capabilities, aws.String("CAPABILITY_IAM"))
capabilitiesMap["CAPABILITY_IAM"] = true
switch typedResource := eachResource.Properties.(type) {
case gocf.IAMRole:
capabilitiesMap["CAPABILITY_NAMED_IAM"] = (typedResource.RoleName != nil)
case *gocf.IAMRole:
capabilitiesMap["CAPABILITY_NAMED_IAM"] = (typedResource.RoleName != nil)
}
}
}
capabilities := make([]*string, 0)
for eachKey := range capabilitiesMap {
capabilities = append(capabilities, aws.String(eachKey))
}
return capabilities
}

Expand Down
13 changes: 12 additions & 1 deletion aws/iam/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package iambuilder

import (
sparta "github.com/mweagle/Sparta"
spartaIAM "github.com/mweagle/Sparta/aws/iam"
gocf "github.com/mweagle/go-cloudformation"
)

Expand Down Expand Up @@ -117,7 +118,17 @@ func (iamRes *IAMPrivilegeBuilder) Literal(arnPart string) *IAMPrivilegeBuilder
return iamRes
}

// ToPrivilege finalizes the builder and returns a sparta.IAMRolePrivilege
// ToPolicyStatement finalizes the builder and returns a spartaIAM.PolicyStatements
func (iamRes *IAMPrivilegeBuilder) ToPolicyStatement() spartaIAM.PolicyStatement {
return spartaIAM.PolicyStatement{
Action: iamRes.resource.apiCalls,
Effect: "Allow",
Resource: gocf.Join("", iamRes.resourceParts...),
}
}

// ToPrivilege returns a legacy sparta.IAMRolePrivilege type for this
// entry
func (iamRes *IAMPrivilegeBuilder) ToPrivilege() sparta.IAMRolePrivilege {
return sparta.IAMRolePrivilege{
Actions: iamRes.resource.apiCalls,
Expand Down
1 change: 1 addition & 0 deletions aws/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type logrusProxy struct {
logger *logrus.Logger
}

// Log is a utility function to comply with the AWS signature
func (proxy *logrusProxy) Log(args ...interface{}) {
proxy.logger.Info(args...)
}
Expand Down
4 changes: 2 additions & 2 deletions buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sparta

// THIS FILE IS AUTOMATICALLY GENERATED
// DO NOT EDIT
// CREATED: Sun Jul 1 07:09:27 PDT 2018
// CREATED: Sat Aug 11 21:05:12 PDT 2018

// SpartaGitHash is the commit hash of this Sparta library
const SpartaGitHash = "b76b71d7b0f9a79f9359f85b2740050eb743fcc3"
const SpartaGitHash = "cb474feae1503f8f526b597f4c7f6544b7a079b6"
Loading

0 comments on commit 2231370

Please sign in to comment.