Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aws/aws-lambda-go
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.13.3
Choose a base ref
...
head repository: aws/aws-lambda-go
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.14.0
Choose a head ref
  • 8 commits
  • 22 files changed
  • 3 contributors

Commits on Nov 13, 2019

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d226cc1 View commit details

Commits on Nov 21, 2019

  1. Update build-lambda-zip instructions for Windows (#251)

    This should mitigate the dependency locking issues people have been reporting
    bmoffatt authored Nov 21, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d89e42d View commit details

Commits on Dec 5, 2019

  1. Fix dead kinesis firehose tests (#254)

    * enable dead firehose event tests
    
    * fix previously dead kinesis firehose tests
    bmoffatt authored Dec 5, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b6af4bf View commit details
  2. Enable CI failures for linting (#164)

    * use golangci-lint
    
    * enable dead firehose event tests
    
    * add some ignore for files that I won't be fixing right now
    
    * fix errcheck problems in cfn/wrap_test.go
    
    * fix errcheck for cfn/wrap.go
    
    * fix previously dead kinesis firehose tests
    bmoffatt authored Dec 5, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6625202 View commit details

Commits on Jan 2, 2020

  1. Update README_Cognito_UserPools_PreSignup.md (#258)

    * Update README_Cognito_UserPools_PreSignup.md
    
    Make the example linter approved.
    
    * Update README_Cognito_UserPools_PreSignup.md
    
    go fmt
    
    Co-authored-by: Bryan Moffatt <bmoffatt@users.noreply.github.com>
    Aaron Mulgrew and bmoffatt committed Jan 2, 2020
    Copy the full SHA
    b76bc6a View commit details

Commits on Jan 3, 2020

  1. Add clientMetadata to cognito triggers that support it (#256)

    Co-authored-by: Bryan Moffatt <bmoffatt@users.noreply.github.com>
    thepelkus-too and bmoffatt committed Jan 3, 2020
    Copy the full SHA
    fb38bd4 View commit details

Commits on Jan 9, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    abc9ba2 View commit details

Commits on Feb 12, 2020

  1. revert #108 to fix #237 (#241)

    bmoffatt authored Feb 12, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b03d958 View commit details
27 changes: 27 additions & 0 deletions .github/workflows/build-lambda-zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: go get build-lambda-zip
on:
push:
schedule:
- cron: "7 7 * * *"

jobs:
thejob:
runs-on: ${{ matrix.platform }}
name: install build-lambda-zip on ${{ matrix.platform }}
strategy:
matrix:
go-version: [1.12, 1.13]
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}

- name: go get
env:
GOPROXY: direct
GO111MODULE: on
run: |
go env
go get -u github.com/aws/aws-lambda-go/cmd/build-lambda-zip
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: tests
on:
push:
pull_request:
schedule:
- cron: "7 7 * * *"

jobs:

test:
name: run tests and lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: golangci-golint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.22.2
./bin/golangci-lint run -v ./...
- name: gofmt check
run: diff -u <(echo -n) <(gofmt -d ./)

- name: go vet
run: go vet -v ./...

- name: go test
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

19 changes: 19 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
run:
skip-files:
# These were code-generated, and cannot be changed without breaking RPC compatability.
- lambda/messages/*.go

# FIXME
# events/codebuild.go:18:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
# CodeBuildPhaseStatusFailed CodeBuildPhaseStatus = "FAILED"
# ^
# events/codebuild.go:31:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
# CodeBuildPhaseTypeSubmitted CodeBuildPhaseType = "SUBMITTED"
# ^
- events/codebuild.go

# FIXME
# events/codedeploy.go:16:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
# CodeDeployDeploymentStateFailure CodeDeployDeploymentState = "FAILURE"
# ^
- events/codedeploy.go
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ before_install:
- go mod download

install:
- go get golang.org/x/lint/golint
- go get github.com/haya14busa/goverage
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0

matrix:
allow_failures:
@@ -24,13 +24,12 @@ notifications:

before_script:
- PKGS=$(go list ./...)
- LINT_PKGS=$(go list ./... | grep -Ev 'aws-lambda-go/lambda')

script:
- diff -u <(echo -n) <(gofmt -d ./) # Fail if a .go file hasn't been formatted with gofmt
- goverage -v -race -covermode=atomic -coverprofile=coverage.txt $PKGS # Run all tests with coverage
- go vet -v ./... # static analyisis
- golint $LINT_PKGS # lint - ignore failures for now
- golangci-lint run ./...

after_success:
- bash <(curl -s https://codecov.io/bash)
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# AWS Lambda for Go
[![GoDoc][1]][2]
[![Build Status][5]][6]
[![GoCard][3]][4]
[![codecov][7]][8]

[1]: https://godoc.org/github.com/aws/aws-lambda-go?status.svg
[2]: https://godoc.org/github.com/aws/aws-lambda-go
[3]: https://goreportcard.com/badge/github.com/aws/aws-lambda-go
[4]: https://goreportcard.com/report/github.com/aws/aws-lambda-go
[5]: https://travis-ci.org/aws/aws-lambda-go.svg?branch=master
[6]: https://travis-ci.org/aws/aws-lambda-go
[7]: https://codecov.io/gh/aws/aws-lambda-go/branch/master/graph/badge.svg
[8]: https://codecov.io/gh/aws/aws-lambda-go

[![tests][1]][2]
[![build-lambda-zip][3]][4]
[![GoDoc][5]][6]
[![GoCard][7]][8]
[![codecov][9]][10]

[1]: https://github.com/aws/aws-lambda-go/workflows/tests/badge.svg
[2]: https://github.com/aws/aws-lambda-go/actions?query=workflow%3Atests
[3]: https://github.com/aws/aws-lambda-go/workflows/go%20get%20build-lambda-zip/badge.svg
[4]: https://github.com/aws/aws-lambda-go/actions?query=workflow%3A%22go+get+build-lambda-zip%22
[5]: https://godoc.org/github.com/aws/aws-lambda-go?status.svg
[6]: https://godoc.org/github.com/aws/aws-lambda-go
[7]: https://goreportcard.com/badge/github.com/aws/aws-lambda-go
[8]: https://goreportcard.com/report/github.com/aws/aws-lambda-go
[9]: https://codecov.io/gh/aws/aws-lambda-go/branch/master/graph/badge.svg
[10]: https://codecov.io/gh/aws/aws-lambda-go

Libraries, samples, and tools to help Go developers develop AWS Lambda functions.

@@ -54,6 +58,7 @@ Windows developers may have trouble producing a zip file that marks the binary a

Get the tool
``` shell
set GO111MODULE=on
go.exe get -u github.com/aws/aws-lambda-go/cmd/build-lambda-zip
```

12 changes: 7 additions & 5 deletions cfn/wrap.go
Original file line number Diff line number Diff line change
@@ -34,23 +34,25 @@ func lambdaWrapWithClient(lambdaFunction CustomResourceFunction, client httpClie
if funcDidPanic {
r.Status = StatusFailed
r.Reason = "Function panicked, see log stream for details"
r.sendWith(client)
// FIXME: something should be done if an error is returned here
_ = r.sendWith(client)
}
}()

r.PhysicalResourceID, r.Data, err = lambdaFunction(ctx, event)
funcDidPanic = false

if r.PhysicalResourceID == "" {
log.Println("PhysicalResourceID must exist, copying Log Stream name")
r.PhysicalResourceID = lambdacontext.LogStreamName
}
if err != nil {
r.Status = StatusFailed
r.Reason = err.Error()
log.Printf("sending status failed: %s", r.Reason)
} else {
r.Status = StatusSuccess

if r.PhysicalResourceID == "" {
log.Println("PhysicalResourceID must exist on creation, copying Log Stream name")
r.PhysicalResourceID = lambdacontext.LogStreamName
}
}

err = r.sendWith(client)
12 changes: 8 additions & 4 deletions cfn/wrap_test.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,8 @@ func TestCopyLambdaLogStream(t *testing.T) {
return
}

lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
lambdacontext.LogStreamName = lgs
}

@@ -72,7 +73,8 @@ func TestPanicSendsFailure(t *testing.T) {
}

assert.Panics(t, func() {
lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
})

assert.True(t, didSendStatus, "FAILED should be sent to CloudFormation service")
@@ -99,7 +101,8 @@ func TestDontCopyLogicalResourceId(t *testing.T) {
return
}

lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
}

func TestWrappedError(t *testing.T) {
@@ -123,7 +126,8 @@ func TestWrappedError(t *testing.T) {
return
}

lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
_, err := lambdaWrapWithClient(fn, client)(context.TODO(), *testEvent)
assert.NoError(t, err)
}

func TestWrappedSendFailure(t *testing.T) {
2 changes: 1 addition & 1 deletion cmd/build-lambda-zip/main.go
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ func main() {
app.Name = "build-lambda-zip"
app.Usage = "Put an executable and supplemental files into a zip file that works with AWS Lambda."
app.Flags = []cli.Flag{
cli.StringFlag{
&cli.StringFlag{
Name: "output, o",
Value: "",
Usage: "output file path for the zip. Defaults to the first input file name.",
15 changes: 8 additions & 7 deletions events/README_Cognito_UserPools_PreSignup.md
Original file line number Diff line number Diff line change
@@ -8,19 +8,20 @@ Please see instructions for setting up the Cognito triggers at https://docs.aws.
package main

import (
"fmt"
"fmt"

"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)

// handler is the lambda handler invoked by the `lambda.Start` function call
func handler(event events.CognitoEventUserPoolsPreSignup) (events.CognitoEventUserPoolsPreSignup, error) {
fmt.Printf("PreSignup of user: %s\n", event.UserName)
event.Response.AutoConfirmUser = true
return event, nil
fmt.Printf("PreSignup of user: %s\n", event.UserName)
event.Response.AutoConfirmUser = true
return event, nil
}

func main() {
lambda.Start(handler)
lambda.Start(handler)
}
```
11 changes: 10 additions & 1 deletion events/cognito.go
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ type CognitoEventUserPoolsHeader struct {
type CognitoEventUserPoolsPreSignupRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
ValidationData map[string]string `json:"validationData"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsPreSignupResponse contains the response portion of a PreSignup event
@@ -110,6 +111,7 @@ type CognitoEventUserPoolsPreAuthenticationResponse struct {
// CognitoEventUserPoolsPostConfirmationRequest contains the request portion of a PostConfirmation event
type CognitoEventUserPoolsPostConfirmationRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsPostConfirmationResponse contains the response portion of a PostConfirmation event
@@ -120,6 +122,7 @@ type CognitoEventUserPoolsPostConfirmationResponse struct {
type CognitoEventUserPoolsPreTokenGenRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
GroupConfiguration GroupConfiguration `json:"groupConfiguration"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsPreTokenGenResponse containst the response portion of a PreTokenGen event
@@ -131,6 +134,7 @@ type CognitoEventUserPoolsPreTokenGenResponse struct {
type CognitoEventUserPoolsPostAuthenticationRequest struct {
NewDeviceUsed bool `json:"newDeviceUsed"`
UserAttributes map[string]string `json:"userAttributes"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsPostAuthenticationResponse contains the response portion of a PostAuthentication event
@@ -139,7 +143,8 @@ type CognitoEventUserPoolsPostAuthenticationResponse struct {

// CognitoEventUserPoolsMigrateUserRequest contains the request portion of a MigrateUser event
type CognitoEventUserPoolsMigrateUserRequest struct {
Password string `json:"password"`
Password string `json:"password"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsMigrateUserResponse contains the response portion of a MigrateUser event
@@ -177,6 +182,7 @@ type CognitoEventUserPoolsChallengeResult struct {
type CognitoEventUserPoolsDefineAuthChallengeRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
Session []*CognitoEventUserPoolsChallengeResult `json:"session"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsDefineAuthChallengeResponse defines auth challenge response parameters
@@ -198,6 +204,7 @@ type CognitoEventUserPoolsCreateAuthChallengeRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
ChallengeName string `json:"challengeName"`
Session []*CognitoEventUserPoolsChallengeResult `json:"session"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsCreateAuthChallengeResponse defines create auth challenge response rarameters
@@ -219,6 +226,7 @@ type CognitoEventUserPoolsVerifyAuthChallengeRequest struct {
UserAttributes map[string]string `json:"userAttributes"`
PrivateChallengeParameters map[string]string `json:"privateChallengeParameters"`
ChallengeAnswer interface{} `json:"challengeAnswer"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsVerifyAuthChallengeResponse defines verify auth challenge response parameters
@@ -247,6 +255,7 @@ type CognitoEventUserPoolsCustomMessageRequest struct {
UserAttributes map[string]interface{} `json:"userAttributes"`
CodeParameter string `json:"codeParameter"`
UsernameParameter string `json:"usernameParameter"`
ClientMetadata map[string]string `json:"clientMetadata"`
}

// CognitoEventUserPoolsCustomMessageResponse contains the response portion of a CustomMessage event
1 change: 1 addition & 0 deletions events/firehose.go
Original file line number Diff line number Diff line change
@@ -39,5 +39,6 @@ type KinesisFirehoseRecordMetadata struct {
ShardID string `json:"shardId"`
PartitionKey string `json:"partitionKey"`
SequenceNumber string `json:"sequenceNumber"`
SubsequenceNumber string `json:"subsequenceNumber"`
ApproximateArrivalTimestamp MilliSecondsEpochTime `json:"approximateArrivalTimestamp"`
}
11 changes: 5 additions & 6 deletions events/firehose_test.go
Original file line number Diff line number Diff line change
@@ -11,20 +11,19 @@ import (
"github.com/stretchr/testify/assert"
)

func testFirehoseEventMarshaling(t *testing.T) {
testMarshaling(t, "./testdata/kinesis-firehose-event.json")
func TestFirehoseEventMarshaling(t *testing.T) {
testMarshaling(t, &KinesisFirehoseEvent{}, "./testdata/kinesis-firehose-event.json")
}

func testFirehoseResponseMarshaling(t *testing.T) {
testMarshaling(t, "./testdata/kinesis-firehose-response.json")
func TestFirehoseResponseMarshaling(t *testing.T) {
testMarshaling(t, &KinesisFirehoseResponse{}, "./testdata/kinesis-firehose-response.json")
}

func testMarshaling(t *testing.T, jsonFile string) {
func testMarshaling(t *testing.T, inputEvent interface{}, jsonFile string) {
// 1. read JSON from file
inputJson := test.ReadJSONFromFile(t, jsonFile)

// 2. de-serialize into Go object
var inputEvent KinesisFirehoseEvent
if err := json.Unmarshal(inputJson, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}
Original file line number Diff line number Diff line change
@@ -23,7 +23,10 @@
"challengeResult": true,
"challengeMetadata": "metadata"
}
]
],
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
}
},
"response": {
"publicChallengeParameters": {
5 changes: 4 additions & 1 deletion events/testdata/cognito-event-userpools-custommessage.json
Original file line number Diff line number Diff line change
@@ -14,7 +14,10 @@
"email_verified": false
},
"codeParameter": "####",
"usernameParameter": "{username}"
"usernameParameter": "{username}",
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
}
},
"response": {
"smsMessage": "<custom message to be sent in the message with code parameter>",
Loading