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
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ This Terraform module is the part of [serverless.tf framework](https://github.co
11
11
3. Create, update, and publish AWS Lambda Function and Lambda Layer - [see usage](#usage).
12
12
4. Create static and dynamic aliases for AWS Lambda Function - [see usage](#usage), see [modules/alias](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/modules/alias).
13
13
5. Do complex deployments (eg, rolling, canary, rollbacks, triggers) - [read more](#deployment), see [modules/deploy](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/modules/deploy).
14
+
6. Use AWS SAM CLI to test Lambda Function - [read more](#sam_cli_integration).
## <aname="sam_cli_integration"></a> How to use AWS SAM CLI to test Lambda Function?
556
+
[AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-command-reference.html) is an open source tool that help the developers to initiate, build, test, and deploy serverless
557
+
applications. Currently, SAM CLI tool only supports CFN applications, but SAM CLI team is working on a feature to extend the testing capabilities to support terraform applications (check this [Github issue](https://github.com/aws/aws-sam-cli/issues/3154)
558
+
to be updated about the incoming releases, and features included in each release for the Terraform support feature).
559
+
560
+
SAM CLI provides two ways of testing: local testing and testing on-cloud (Accelerate).
561
+
562
+
### Local Testing
563
+
Using SAM CLI, you can invoke the lambda functions defined in the terraform application locally using the [sam local invoke](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-invoke.html)
564
+
command, providing the function terraform address, or function name, and to set the `hook-package-id` to `terraform` to tell SAM CLI that the underlying project is a terraform application.
565
+
566
+
You can execute the `sam local invoke` command from your terraform application root directory as following:
567
+
```
568
+
sam local invoke --hook-package-id terraform module.hello_world_function.aws_lambda_function.this[0]
569
+
```
570
+
You can also pass an event to your lambda function, or overwrite its environment variables. Check [here](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-invoke.html) for more information.
571
+
572
+
You can also invoke your lambda function in debugging mode, and step-through your lambda function source code locally in your preferred editor. Check [here](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging.html) for more information.
573
+
574
+
### Testing on-cloud (Accelerate)
575
+
You can use AWS SAM CLI to quickly test your application on your AWS development account. Using SAM Accelerate, you will be able to develop your lambda functions locally,
576
+
and once you save your updates, SAM CLI will update your development account with the updated Lambda functions. So, you can test it on cloud, and if there is any bug,
577
+
you can quickly update the code, and SAM CLI will take care of pushing it to the cloud. Check [here](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/accelerate.html) for more information about SAM Accelerate.
578
+
579
+
You can execute the `sam sync` command from your terraform application root directory as following:
580
+
```
581
+
sam sync --hook-package-id terraform --watch
582
+
```
583
+
554
584
## <aname="deployment"></a> How to deploy and manage Lambda Functions?
0 commit comments