Skip to content

Commit 92a9843

Browse files
committed
2 parents e31c9a1 + c6725b7 commit 92a9843

36 files changed

+314
-50
lines changed

.github/workflows/reviewdog.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: reviewdog
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
test:
7+
name: lint
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Check out code into the Go module directory
11+
uses: actions/checkout@v2
12+
13+
- name: golangci-lint
14+
uses: reviewdog/action-golangci-lint@v1
15+
with:
16+
level: warning
17+
reporter: github-pr-review

.github/workflows/tests.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
name: tests
2-
on:
2+
on:
33
push:
44
pull_request:
55

66
jobs:
7-
87
test:
9-
name: run tests with code coverage
8+
name: run tests with code coverage
109
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
go:
13+
- "1.16"
14+
- "1.15"
15+
- "1.14"
16+
- "1.13"
17+
1118
steps:
12-
- name: Set up Go 1.13
19+
- name: Set up Go ${{ matrix.go }}
1320
uses: actions/setup-go@v1
1421
with:
15-
go-version: 1.13
22+
go-version: ${{ matrix.go }}
1623
id: go
1724

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

2128
- name: go test
2229
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
23-
24-
- name: Upload coverage to Codecov
30+
31+
- name: Upload coverage to Codecov
2532
uses: codecov/codecov-action@v1
33+
if: matrix.go == '1.16'
2634
with:
27-
file: ./coverage.txt
35+
file: ./coverage.txt

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
[![tests][1]][2]
44
[![build-lambda-zip][3]][4]
5-
[![GoDoc][5]][6]
5+
[![Go Reference][5]][6]
66
[![GoCard][7]][8]
77
[![codecov][9]][10]
88

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

events/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overview
22

3-
[![GoDoc](https://godoc.org/github.com/aws/aws-lambda-go/events?status.svg)](https://godoc.org/github.com/aws/aws-lambda-go/events)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/aws/aws-lambda-go/events.svg)](https://pkg.go.dev/github.com/aws/aws-lambda-go/events)
44

55
This package provides input types for Lambda functions that process AWS events.
66

@@ -12,6 +12,8 @@ This package provides input types for Lambda functions that process AWS events.
1212

1313
[AppSync](README_AppSync.md)
1414

15+
[ClientVPN Connection Handler](README_ClientVPN.md)
16+
1517
[CloudFormation Events](../cfn/README.md)
1618

1719
[CloudWatch Events](README_CloudWatch_Events.md)

events/README_ALBTargetGroupEvents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-funct
66

77
# Sample Function
88

9-
The following is a sample class and Lambda function that receives an ALB Target Group event as an input, writes some of the incoming data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
9+
The following is a sample class and Lambda function that receives an ALB Target Group event as an input, writes some of the incoming data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.)
1010

1111
```go
1212

events/README_ApiGatewayEvent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ API Gateway events consist of a request that was routed to a Lambda function by
44

55
# Sample Function
66

7-
The following is a sample class and Lambda function that receives Amazon API Gateway event record data as an input, writes some of the record data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
7+
The following is a sample class and Lambda function that receives Amazon API Gateway event record data as an input, writes some of the record data to CloudWatch Logs, and responds with a 200 status and the same body as the request. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.)
88

99
```go
1010

events/README_AutoScaling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sample Function
22

3-
The following is a sample Lambda function that receives an Auto Scaling event as an input and logs the EC2 instance ID to CloudWatch Logs. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
3+
The following is a sample Lambda function that receives an Auto Scaling event as an input and logs the EC2 instance ID to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.)
44

55
```go
66
import (

events/README_ClientVPN.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Sample Function
2+
3+
The following is a sample Lambda function that receives a Client VPN connection handler request as an input and then validates the IP address input and checks whether the connection source IP is on the allowed list defined as a map inside the function. If the source IP matches an allowed IP address it allows the access, otherwise an error message is presented to the user. Debug logs are generated to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.)
4+
5+
```go
6+
import (
7+
"fmt"
8+
"log"
9+
"net"
10+
11+
"encoding/json"
12+
13+
"github.com/aws/aws-lambda-go/events"
14+
"github.com/aws/aws-lambda-go/lambda"
15+
)
16+
17+
var (
18+
AllowedIPs = map[string]bool{
19+
"10.11.12.13": true,
20+
}
21+
)
22+
23+
func handler(request events.ClientVPNConnectionHandlerRequest) (events.ClientVPNConnectionHandlerResponse, error) {
24+
requestJson, _ := json.MarshalIndent(request, "", " ")
25+
log.Printf("REQUEST: %s", requestJson)
26+
27+
sourceIP := request.PublicIP
28+
if net.ParseIP(sourceIP) == nil {
29+
return events.ClientVPNConnectionHandlerResponse{}, fmt.Errorf("Invalid parameter PublicIP passed in request: %q", sourceIP)
30+
}
31+
32+
log.Printf("SOURCE IP: %q", sourceIP)
33+
34+
if allowed, ok := AllowedIPs[sourceIP]; ok && allowed {
35+
log.Printf("Allowing access from: %q", sourceIP)
36+
return events.ClientVPNConnectionHandlerResponse{
37+
Allow: true,
38+
ErrorMsgOnFailedPostureCompliance: "",
39+
PostureComplianceStatuses: []string{},
40+
SchemaVersion: "v1",
41+
}, nil
42+
}
43+
44+
log.Printf("Blocking access from: %q", sourceIP)
45+
return events.ClientVPNConnectionHandlerResponse{
46+
Allow: false,
47+
ErrorMsgOnFailedPostureCompliance: "You're trying to connect from an IP address that is not allowed.",
48+
PostureComplianceStatuses: []string{"BlockedSourceIP"},
49+
SchemaVersion: "v1",
50+
}, nil
51+
}
52+
53+
func main() {
54+
lambda.Start(handler)
55+
}
56+
```

events/README_Cognito.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sample Function
22

3-
The following is a sample Lambda function that receives Amazon Cognito Sync event record data as an input and writes some of the record data to CloudWatch Logs. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
3+
The following is a sample Lambda function that receives Amazon Cognito Sync event record data as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.)
44

55
```go
66

events/README_Cognito_UserPools_PostConfirmation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Sample Function
22

3-
The following is a sample Lambda function that receives Amazon Cognito User Pools post-confirmation event as an input and writes some of the record data to CloudWatch Logs. (Note that by default anything written to Console will be logged as CloudWatch Logs events.)
3+
The following is a sample Lambda function that receives Amazon Cognito User Pools post-confirmation event as an input and writes some of the record data to CloudWatch Logs. (Note that anything written to stdout or stderr will be logged as CloudWatch Logs events.)
44

55
Please see instructions for setting up the Cognito triggers at https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html .
66

0 commit comments

Comments
 (0)