Skip to content

Commit fb812d6

Browse files
committed
Update install and deploy instructions
1 parent 2a908ab commit fb812d6

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

README.md

+35-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
1-
This is an initial attempt to test Lambda Powertools for TypeScript running on LocalStack. Currently there are just two basic examples of the Logger and the Tracer.
1+
## Powertools for AWS Lambda (TypeScript) in LocalStack
22

3-
You'll need to follow these steps to install all the dependencies before you can run this:
3+
[Powertools for AWS Lambda](https://docs.powertools.aws.dev/lambda/typescript/latest/) provide implementations of best practices for Lambda function development that are easy to integrate into your existing Lambda functions.
4+
5+
This examples repository provides basic examples of the TypeScript implementation Powertools that can be run and tested in [LocalStack](https://localstack.cloud). The good news is that Powertools (including the logger, metrics, parameters, tracer and idempotency shown here) can be used "out of the box" in LocalStack.
6+
7+
### Setup, Deployment and Testing the Examples
8+
9+
The easiest way to test these examples is to use the provided Makefile. Start by installing the necessary dependencies:
10+
11+
```bash
12+
make install
13+
```
14+
15+
Ensure that you have LocalStack running on your machine and then run the deploy command for the example you wish to run. For example:
16+
17+
```bash
18+
make deploy-idempotency
19+
```
20+
21+
Once the deployment is finished, invoke the Lambda function. For example:
22+
23+
```bash
24+
make invoke-idempotency
25+
```
26+
27+
### Manually Setup, Deployment and Testing the Examples
28+
29+
The examples are set up to enable easy deployment and testing of the particular Powertool library you wish to use. Each example has a lambda folder containing the example Lambda and a CDK folder containing the CDK script needed to deploy the example. You will need the AWS CLI, AWS CDK CLI, LocalStack, `awslocal` and `cdklocal` installed.
30+
31+
You'll need to run npm install within the directories for the example you wish to run. For instance:
432

533
```bash
634
cd tracer-lambda
735
npm install
8-
cd ../logger-lambda
9-
npm install
10-
cd ../cdk
36+
cd ../tracer-cdk
1137
npm install
1238
```
1339

14-
Now you can bootstrap and deploy using LocalStack's CDK wrapper.
40+
Next, you can bootstrap and deploy using LocalStack's CDK wrapper from within the CDK folder for the example you wish to deploy to LocalStack.
1541

1642
```bash
1743
cdklocal bootstrap
1844
cdklocal deploy
1945
```
2046

21-
The output will include the names of the deployed functions, which you can test using `awslocal` (replacing `PowerToolsCdkStack-loggerFunction` with the outputted function name):
47+
The output will include the names of the deployed functions, which you can test using `awslocal` (replacing `TracerStack-tracerFunction` with the outputted function name):
2248

2349
```bash
24-
awslocal lambda invoke --function-name PowerTools-loggerFunction output.txt
50+
awslocal lambda invoke --function-name TracerStack-tracerFunction output.txt
2551
```
26-
At this point, the logger function output can be seen in CloudWatch. The tracer function just runs. Updating these with better examples soon.
52+
Note that the idempotency example does require passing a JSON payload containing a `productId` and `customer` (see the Makefile for an example on how to call this function manually).

0 commit comments

Comments
 (0)