Skip to content

Commit 5950464

Browse files
committed
First commit
1 parent 23bae20 commit 5950464

File tree

6 files changed

+55
-1
lines changed

6 files changed

+55
-1
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ignore lambda packages
2+
package/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

Diff for: README.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
# py-lambda-redis
1+
# py-lambda-redis
2+
3+
- install package in local
4+
5+
`pip3 install -r requirements.txt --target ./package redis`
6+
7+
- package
8+
9+
```bash
10+
cd package
11+
zip -r ../my-deployment-package.zip .
12+
cd ..
13+
zip -g my-deployment-package.zip lambda_function.py
14+
```
15+
16+
- deploy
17+
18+
```bash
19+
aws lambda update-function-code \
20+
--function-name PyLambdaRedis \
21+
--zip-file fileb://my-deployment-package.zip
22+
```

Diff for: deploy.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
aws lambda update-function-code \
2+
--function-name PyLambdaRedis \
3+
--zip-file fileb://my-deployment-package.zip

Diff for: lambda_function.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import redis
2+
import json
3+
4+
def lambda_handler(event, context):
5+
print('hello_world')
6+
7+
r = redis.Redis(host='localhost', port=6379, db=0)
8+
print('set-----------------')
9+
r.set('foo', 'bar')
10+
print('get-----------------')
11+
foo = r.get('foo')
12+
print(f'foo: {foo}')
13+
14+
return {
15+
'statusCode': 200,
16+
'body': json.dumps('Hello from Lambda!')
17+
}
18+
19+
20+
if __name__ == '__main__':
21+
lambda_handler(None, None)
22+
pass

Diff for: package.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cd package
2+
zip -r ../my-deployment-package.zip .
3+
cd ..
4+
zip -g my-deployment-package.zip lambda_function.py

Diff for: requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
redis == 3.5.3

0 commit comments

Comments
 (0)