You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-49Lines changed: 32 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,23 @@
1
-
# lambda_localstack_template
2
-
Template for lambda with localstack and sam integration for localtest
1
+
# nci-aws-lambda-localstack-template
2
+
3
+
This provides a templates for aws lambda test in local environment using localstack or local server instances (i.e. dynamoDB). This examples shows only fraction of the services localstack provides. The full list of services are [here](https://github.com/localstack/localstack). This template provides the basic settings for local test which can be used in different projects with minimal configuration changes. Details for the configuration changes is explained `How to use this template` section below.
*[Docker](https://docs.docker.com/docker-for-mac/install/) - need for the local lambda function testing with sam
9
10
10
-
*[AWS SAM client](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html#serverless-sam-cli-install-mac-pip) (pip3 install --user aws-sam-cli)
11
-
12
-
* Reference: [Adjust path to use sam cli command](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac-path.html)
`pip install -r requirements.txt` - one time setting
53
60
(If install fails with __xcun__ error, run __xcode-select --install__)
54
-
55
-
56
-
* To start local test setup
61
+
62
+
* Now it is ready to set up the test below.
63
+
64
+
* After all the test is done. get out of virtual environment.
57
65
58
-
`./start_local_test_template.sh`
66
+
`deactivate`
59
67
60
-
_-i_ option sets interactive mode on localstack instead of running it background, if you want to monitor localstack log use this option. Without this option, it automatically create the sample data in S3 bucket.
61
-
68
+
## Tests Examples
62
69
63
-
* To check the table, sqs and bucket are created (**Use this setting only if you use _-i_ option, without _-i_, these steps runs automatically**)
### [Lambda with dynamo, API gateway testing (local dynamo server)](https://github.com/BIAD/nci-aws-lambda-localstack-template/wiki/Lambda-Local-Dynamo-Server-Test)
81
76
82
-
* invoke SQS event
83
-
84
-
`sam local invoke TestLambda -t build/template.yaml --docker-network lambda_localstack_template_local_aws_network -e tests/sqs_test_event.json`
## [How to use this template](https://github.com/BIAD/nci-aws-lambda-localstack-template/wiki/How-to-use-this-template)
99
82
100
-
## Integration Test: To be added
83
+
* goal: With minimal configuation change, testing environment can be set up for different project.
84
+
* There are two main configuration - One for localstack and one for sam. If starting and stop scrip need to be changed as well if you want to reuse the script.
101
85
102
-
103
86
## Reference
104
87
*[AWS SAM guick start guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html)
# Set environment variable so amazon service can be switched in local settings
12
+
# This has to be matched with localstack config in docker-compose.yaml
13
+
# Current example contains DynamoDB
14
+
TEST_ENV: LOCAL
15
+
16
+
Resources:
17
+
PostTest:
18
+
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
0 commit comments