Skip to content

Commit ce45546

Browse files
authored
First Commit for AWS Lambda Runtime Interface Emulator (aws#1)
* First Commit for AWS Lambda Runtime Interface Emulator * Fix merge conflict Co-authored-by: Jacob Fuss <[email protected]>
1 parent a1ef335 commit ce45546

File tree

146 files changed

+14224
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+14224
-7
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/pkg
2+
/build
3+
/bin
4+
*.swp
5+
*.iml
6+
tags
7+
.idea
8+
.DS_Store
9+
.venv

CONTRIBUTING.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ reported the issue. Please try to include as much information as you can. Detail
1919
* Any modifications you've made relevant to the bug
2020
* Anything unusual about your environment or deployment
2121

22+
IMPORTANT: Everything under `/lambda` is a mirrored version of AWS Lambda's Runtime API. Due to this, we are not accepting
23+
contributions to any code within this directory.
24+
2225

2326
## Contributing via Pull Requests
2427
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
@@ -31,7 +34,7 @@ To send us a pull request, please:
3134

3235
1. Fork the repository.
3336
2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34-
3. Ensure local tests pass.
37+
3. Ensure local tests pass through `make integ-tests-and-compile`
3538
4. Commit to your fork using clear commit messages.
3639
5. Send us a pull request, answering any default questions in the pull request interface.
3740
6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# RELEASE_BUILD_LINKER_FLAGS disables DWARF and symbol table generation to reduce binary size
2+
RELEASE_BUILD_LINKER_FLAGS=-s -w
3+
4+
BINARY_NAME=aws-lambda-rie
5+
DESTINATION=bin/${BINARY_NAME}
6+
7+
compile-with-docker:
8+
docker run --env GOPROXY=direct -v $(shell pwd):/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.14 make compile-lambda-linux
9+
10+
compile-lambda-linux:
11+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "${RELEASE_BUILD_LINKER_FLAGS}" -o ${DESTINATION} ./cmd/aws-lambda-rie
12+
13+
tests:
14+
go test ./...
15+
16+
integ-tests-and-compile: compile-lambda-linux
17+
python3 -m venv .venv
18+
.venv/bin/pip install --upgrade pip
19+
.venv/bin/pip install requests
20+
.venv/bin/python3 test/integration/local_lambda/end-to-end-test.py
21+
22+
integ-tests-with-docker: compile-with-docker
23+
python3 -m venv .venv
24+
.venv/bin/pip install --upgrade pip
25+
.venv/bin/pip install requests
26+
.venv/bin/python3 test/integration/local_lambda/end-to-end-test.py
27+
28+
integ-tests:
29+
python3 -m venv .venv
30+
.venv/bin/pip install --upgrade pip
31+
.venv/bin/pip install requests
32+
.venv/bin/python3 test/integration/local_lambda/end-to-end-test.py

README.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,59 @@
1-
## My Project
1+
## AWS Lambda Runtime Interface Emulator
22

3-
TODO: Fill this README out!
3+
![Apache-2.0](https://img.shields.io/npm/l/aws-sam-local.svg)
44

5-
Be sure to:
5+
AWS Lambda Runtime Interface Emulator emulates the AWS Lambda Runtime API. This can be used to run your Lambda Functions
6+
locally through a container tooling, such as Docker. When `aws-lambda-rie` is executed, a
7+
/2015-03-31/functions/function/invocations endpoint will be stood up within the container that you post data to it in
8+
order to invoke your function for testing.
69

7-
* Change the title in this README
8-
* Edit your repository description on GitHub
10+
Installing
11+
12+
Instructions for installing AWS Lambda Runtime Interface Emulator for your platform
13+
14+
| Platform | Command to install |
15+
|---------|---------
16+
| macOS | `mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && chmod +x ~/.aws-lambda-rie/aws-lambda-rie` |
17+
| Linux | `mkdir -p ~/.aws-lambda-rie && curl -Lo ~/.aws-lambda-rie/aws-lambda-rie https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie && chmod +x ~/.aws-lambda-rie/aws-lambda-rie` |
18+
| Windows | `Invoke-WebRequest -OutFile 'C:\Program Files\aws lambda\aws-lambda-rie' https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie` |
19+
20+
21+
Getting started
22+
23+
Download the `aws-lambda-rie` binary (see Installing instructions above).
24+
Once downloaded you need to mount the binary into Lambda Image locally and use it as the entrypoint.
25+
26+
Linux and macOS:
27+
docker run -d -v ~/.aws-lambda-rie:/aws-lambda -p 9000:8080 \
28+
--entrypoint /aws-lambda/aws-lambda-rie myfunction:latest \
29+
/bootstrap-with-handler app.lambda_handler
30+
31+
Windows:
32+
docker run -d -v /c/Program Files/aws lambda:/aws-lambda -p 9000:8080 \
33+
--entrypoint /aws-lambda/aws-lambda-rie myfunction:latest \
34+
/bootstrap-with-handler app.lambda_handler
35+
36+
How to configure
37+
38+
`aws-lambda-rie` can be configured through Environment Variables within the local running Image.
39+
You can configure your credentials by setting:
40+
* AWS_ACCESS_KEY_ID
41+
* AWS_SECRET_ACCESS_KEY
42+
* AWS_SESSION_TOKEN
43+
* AWS_REGION
44+
45+
You can configure timeout by setting AWS_LAMBDA_FUNCTION_TIMEOUT to the number of seconds you want your function to timeout in.
46+
47+
The rest of these Environment Variables can be set to match AWS Lambda's environment but are not required.
48+
* AWS_LAMBDA_FUNCTION_VERSION
49+
* AWS_LAMBDA_FUNCION_NAME
50+
* AWS_LAMBDA_MEMORY_SIZE
51+
52+
Limitations
53+
54+
* There is no X-Ray support locally
55+
* Only supports linux x84-64 architectures
56+
* The emulator runs in a running container
957

1058
## Security
1159

@@ -14,4 +62,3 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform
1462
## License
1563

1664
This project is licensed under the Apache-2.0 License.
17-

THIRD-PARTY-LICENSES.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
** Go3p-Github-Pkg-Errors; version 1.x --
2+
https://godoc.org/github.com/pkg/errors
3+
Copyright (c) 2015, Dave Cheney <[email protected]>
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
------
28+
29+
** Go3p-Golang-X-Sys; version 1.x -- https://github.com/golang/sys
30+
Copyright (c) 2009 The Go Authors. All rights reserved.
31+
** go; version 1.13.8 -- https://github.com/golang/go/
32+
Copyright (c) 2009 The Go Authors. All rights reserved.
33+
** Go3p-Github-Jessevdk-GoFlags; version 0.1.0 --
34+
https://github.com/jessevdk/go-flags
35+
Copyright (c) 2012 Jesse van den Kieboom. All rights reserved.
36+
** Go3p-Golang-X-Crypto; version 20180728-614d502 --
37+
https://tip.golang.org/pkg/crypto/
38+
Copyright (c) 2009 The Go Authors. All rights reserved.
39+
** Go3p-Golang-X-Net; version 20180521-5706520 --
40+
https://tip.golang.org/pkg/net/
41+
Copyright (c) 2009 The Go Authors. All rights reserved.
42+
** Go3p-Golang-X-Text; version 1.x -- https://tip.golang.org/pkg/text
43+
Copyright (c) 2009 The Go Authors. All rights reserved.
44+
** google-uuid; version 1.0 -- https://github.com/google/uuid
45+
Copyright (c) 2009,2014 Google Inc. All rights reserved.
46+
47+
Redistribution and use in source and binary forms, with or without
48+
modification, are permitted provided that the following conditions are
49+
met:
50+
51+
* Redistributions of source code must retain the above copyright
52+
notice, this list of conditions and the following disclaimer.
53+
* Redistributions in binary form must reproduce the above
54+
copyright notice, this list of conditions and the following disclaimer
55+
in the documentation and/or other materials provided with the
56+
distribution.
57+
* Neither the name of Google Inc. nor the names of its
58+
contributors may be used to endorse or promote products derived from
59+
this software without specific prior written permission.
60+
61+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
62+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
63+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
64+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
65+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
66+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
67+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
68+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
69+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
70+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
71+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
72+
73+
------
74+
75+
** Go3p-Github-GoChi-Chi; version 3.3.2 -- https://github.com/go-chi/chi
76+
Copyright (c) 2015-present Peter Kieltyka (https://github.com/pkieltyka),
77+
Google Inc.
78+
** Go3p-Github-GoChi-Render; version 1.0.0 -- https://github.com/go-chi/render
79+
Copyright (c) 2016-Present https://github.com/go-chi authors
80+
81+
MIT License
82+
83+
Permission is hereby granted, free of charge, to any person obtaining a copy of
84+
this software and associated documentation files (the "Software"), to deal in
85+
the Software without restriction, including without limitation the rights to
86+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
87+
of
88+
the Software, and to permit persons to whom the Software is furnished to do so,
89+
subject to the following conditions:
90+
91+
The above copyright notice and this permission notice shall be included in all
92+
copies or substantial portions of the Software.
93+
94+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96+
FITNESS
97+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
98+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
99+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
100+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
101+
102+
------
103+
104+
** Go3p-Golang-X-Sync; version 1.x -- https://github.com/golang/sync/
105+
Copyright (c) 2009 The Go Authors. All rights reserved.
106+
107+
Redistribution and use in source and binary forms, with or without
108+
modification, are permitted provided that the following conditions are
109+
met:
110+
111+
* Redistributions of source code must retain the above copyright
112+
notice, this list of conditions and the following disclaimer.
113+
* Redistributions in binary form must reproduce the above
114+
copyright notice, this list of conditions and the following disclaimer
115+
in the documentation and/or other materials provided with the
116+
distribution.
117+
* Neither the name of Google Inc. nor the names of its
118+
contributors may be used to endorse or promote products derived from
119+
this software without specific prior written permission.
120+
121+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
122+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
123+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
124+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
125+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
126+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
127+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
128+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
129+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
130+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
131+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
132+
133+
------
134+
135+
** sirupsen-logrus; version 1.0.6 -- https://github.com/sirupsen/logrus
136+
Copyright (c) 2014 Simon Eskildsen
137+
138+
The MIT License (MIT)
139+
140+
Permission is hereby granted, free of charge, to any person obtaining a copy
141+
of this software and associated documentation files (the "Software"), to deal
142+
in the Software without restriction, including without limitation the rights
143+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
144+
copies of the Software, and to permit persons to whom the Software is
145+
furnished to do so, subject to the following conditions:
146+
147+
The above copyright notice and this permission notice shall be included in
148+
all copies or substantial portions of the Software.
149+
150+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
153+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
154+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
155+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
156+
THE SOFTWARE.
157+
158+
------
159+
160+
** Go3p-Github-Satori-GoUUID; version 1.1.0 --
161+
https://github.com/satori/go.uuid
162+
Copyright (C) 2013-2016 by Maxim Bublis <[email protected]>
163+
164+
Permission is hereby granted, free of charge, to any person obtaining
165+
a copy of this software and associated documentation files (the
166+
"Software"), to deal in the Software without restriction, including
167+
without limitation the rights to use, copy, modify, merge, publish,
168+
distribute, sublicense, and/or sell copies of the Software, and to
169+
permit persons to whom the Software is furnished to do so, subject to
170+
the following conditions:
171+
172+
The above copyright notice and this permission notice shall be
173+
included in all copies or substantial portions of the Software.
174+
175+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
176+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
177+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
178+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
179+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
180+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
181+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)