Skip to content

Commit d28cbd8

Browse files
dreamorosiijemmyflochaz
authored and
Florian Chazal
committed
chore(examples): updated contributing & docs with SAM (#876)
* chore: updated contributing & docs with SAM * chore: updated contributing & docs with SAM * chore: updated contributing & docs with SAM * chore: updated contributing & docs with SAM * chore: updated contributing & docs with SAM * chore: updated contributing & docs with SAM * chore: add sam to gitpod * chore: updated gitpod.yml * chore: updated gitpod.yml * chore: updated gitpod.yml * Update CONTRIBUTING.md Co-authored-by: ijemmy <[email protected]> * Update .devcontainer/devcontainer.json Co-authored-by: Florian Chazal <[email protected]> Co-authored-by: ijemmy <[email protected]> Co-authored-by: Florian Chazal <[email protected]>
1 parent 5d4d7b7 commit d28cbd8

File tree

10 files changed

+68
-25
lines changed

10 files changed

+68
-25
lines changed

Diff for: .devcontainer/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
1111
# ARG EXTRA_NODE_VERSION=10
1212
# RUN su node -c "umask 0002 && ./usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
1313

14+
RUN wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip \
15+
&& unzip aws-sam-cli-linux-x86_64.zip -d sam-installation \
16+
&& sudo ./sam-installation/install \
17+
&& rm -rf sam-installation aws-sam-cli-linux-*
18+
1419
# Global node modules
1520
RUN su node -c "npm install -g npm-check-updates npm@next-8"

Diff for: .devcontainer/devcontainer.json

+7-9
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
"build": {
66
"dockerfile": "Dockerfile",
77
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
8-
// Append -bullseye or -buster to pin to an OS version.
9-
// Use -bullseye variants on local arm64/Apple Silicon.
10-
"args": { "VARIANT": "16-bullseye" }
8+
// Append -bullseye or -buster to pin to an OS version.
9+
// Use -bullseye variants on local arm64/Apple Silicon.
10+
"args": {
11+
"VARIANT": "16-bullseye"
12+
}
1113
},
12-
1314
// Set *default* container specific settings.json values on container create.
1415
"settings": {
1516
"git.enableCommitSigning": true
1617
},
17-
1818
// Add the IDs of extensions you want installed when the container is created.
1919
"extensions": [
2020
"dbaeumer.vscode-eslint",
@@ -25,10 +25,8 @@
2525
"ms-vscode.vscode-typescript-tslint-plugin",
2626
"ms-azuretools.vscode-docker"
2727
],
28-
2928
// Use 'postCreateCommand' to run commands after the container is created.
30-
"postCreateCommand": "npm ci; npm run lerna-ci; npm run init-environment",
31-
29+
"postCreateCommand": "npm ci --foreground-scripts; cd examples/cdk; npm ci; cd ../sam; npm ci; cd ../../; npm run init-environment",
3230
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
33-
"remoteUser": "node"
31+
"remoteUser": "node"
3432
}

Diff for: .gitpod.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
tasks:
2-
- init: nvm install; nvm use; npm i -g npm@next-8; npm ci; npm run lerna-ci; npm run init-environment
2+
- init: |
3+
# Install Nodejs version specified in .nvmrc
4+
nvm install
5+
nvm use
6+
# Install npm 8.x
7+
npm i -g npm@next-8
8+
# Install monorepo packages
9+
npm ci --foreground-scripts
10+
# Install CDK exampels dependencies
11+
cd examples/cdk
12+
npm ci
13+
# Install SAM exampels dependencies
14+
cd ../sam
15+
npm ci
16+
# Install AWS SAM CLI
17+
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip
18+
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
19+
sudo ./sam-installation/install
20+
rm -rf sam-installation aws-sam-cli-linux-*
21+
cd ../../
22+
# Setup husky hooks
23+
npm run init-environment
324
vscode:
425
extensions:
526
- dbaeumer.vscode-eslint

Diff for: CONTRIBUTING.md

+23-10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ reported the issue. Please try to include as much information as you can. Detail
5757
The following steps describe how to set up the AWS Lambda Powertools for TypeScript repository on your local machine.
5858
The alternative is to use a Cloud IDE like [Gitpod](https://www.gitpod.io/) or [Codespaces](https://github.com/features/codespaces) for your development.
5959

60+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/awslabs/aws-lambda-powertools-typescript)
61+
6062
### Setup
6163

6264
The following tools need to be installed on your system prior to starting working on a pull request:
@@ -66,6 +68,8 @@ The following tools need to be installed on your system prior to starting workin
6668
- If you use [nvm](https://github.com/nvm-sh/nvm#nvmrc) or [fnm](https://github.com/Schniz/fnm) you can install the latest LTS version with `nvm use` or `fnm use` respectively. Both will use the `.nvmrc` file in the project's root.
6769
- [npm 8.x](https://www.npmjs.com/)
6870
- After installing Node.js, you can install `npm` with `npm install -g npm@next-8`
71+
- [AWS SAM CLI >= 1.49.0](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
72+
- AWS SAM CLI is a command line interface for AWS Serverless Application Model (SAM), it's used in one of the examples, and it's part of the pre-push hook.
6973
- [Docker](https://docs.docker.com/get-docker/)
7074
- If you are not planning on making changes to the documentation, you can skip this step.
7175

@@ -74,9 +78,10 @@ First, [fork](https://docs.github.com/en/get-started/quickstart/fork-a-repo) the
7478
```console
7579
git clone https://github.com/{your-account}/aws-lambda-powertools-typescript.git
7680
cd aws-lambda-powertools-typescript
77-
npm ci;
81+
npm ci --foreground-scripts;
7882
cd examples/cdk; npm ci
7983
cd ../..
84+
cd examples/sam; npm ci
8085
npm run init-environment
8186
```
8287

@@ -195,26 +200,34 @@ You can run the end-to-end tests automatically on your forked project by followi
195200
196201
### Examples
197202

198-
As part of the repo you will find an examples folder at the root. This folder contains examples (written with CDK for now) of deployable AWS Lambda functions using Powertools.
203+
As part of the repo you will find an examples folder at the root. This folder contains examples (written with CDK and SAM) of deployable AWS Lambda functions using Powertools.
199204

200205
To test your updates with these examples, you just have to:
201206

202-
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package`
203-
2. Update their references in examples
207+
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package` while in the root folder
208+
2. Move to the examples folder of your choice
209+
```sh
210+
cd packages/examples/cdk
211+
# or
212+
cd packages/examples/sam
204213
```
205-
cd examples/cdk
214+
3. Update their references in examples
215+
```sh
206216
npm install ../../packages/**/dist/aws-lambda-powertools-*
207217
```
208-
3. Run cdk tests
209-
```
218+
4. Run cdk tests
219+
```sh
210220
npm run test
211221
```
212-
4. Deploy
213-
```
222+
5. Deploy
223+
```sh
214224
npm run cdk deploy
225+
# or
226+
sam build --beta-features
227+
sam deploy --guided
215228
```
216229

217-
The last command will deploy AWS resources, therefore, you will need an AWS account, and it might incur some costs which should be covered by the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). If you don't have an AWS Account, follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
230+
The last step will deploy AWS resources, therefore, you will need an AWS account, and it might incur some costs which should be covered by the [AWS Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). If you don't have an AWS Account, follow [these instructions to create one](https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/).
218231
219232
### Local documentation
220233

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools for [Python](https://github.com/awslabs/aws-lambda-powertools-python) and AWS Lambda Powertools for [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available).
88

9-
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)**
9+
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples)**
1010

1111
> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | [email protected]**
1212
@@ -44,6 +44,7 @@ Each TypeScript utility is installed as standalone NPM package.
4444
### Examples
4545

4646
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)
47+
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam)
4748
* [Tracer](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk/src)
4849
* [Logger](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/logger/examples)
4950
* [Metrics](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/metrics/examples)

Diff for: docs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Each TypeScript utility is installed as standalone NPM package.
6363
## Examples
6464

6565
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk){target="_blank"}
66+
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam){target="_blank"}
6667
* [Tracer](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk/lib){target="_blank"}
6768
* [Logger](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/logger/examples){target="_blank"}
6869
* [Metrics](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/metrics/examples){target="_blank"}

Diff for: packages/commons/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools for [Python](https://github.com/awslabs/aws-lambda-powertools-python) and AWS Lambda Powertools for [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available).
99

10-
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)**
10+
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples)**
1111

1212
> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | [email protected]**
1313
@@ -35,6 +35,7 @@ Each TypeScript utility is installed as standalone NPM package.
3535
### Examples
3636

3737
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)
38+
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam)
3839
* [Tracer](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/tracing/examples)
3940
* [Logger](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/logger/examples)
4041
* [Metrics](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/metrics/examples)

Diff for: packages/logger/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools for [Python](https://github.com/awslabs/aws-lambda-powertools-python) and AWS Lambda Powertools for [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available).
99

10-
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)**
10+
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples)**
1111

1212
> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | [email protected]**
1313
@@ -36,6 +36,7 @@ Each TypeScript utility is installed as standalone NPM package.
3636
### Examples
3737

3838
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)
39+
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam)
3940
* [Tracer](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/tracing/examples)
4041
* [Logger](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/logger/examples)
4142
* [Metrics](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/metrics/examples)

Diff for: packages/metrics/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools for [Python](https://github.com/awslabs/aws-lambda-powertools-python) and AWS Lambda Powertools for [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available).
99

10-
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)**
10+
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples)**
1111

1212
> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | [email protected]**
1313
@@ -35,6 +35,7 @@ Each TypeScript utility is installed as standalone NPM package.
3535
### Examples
3636

3737
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)
38+
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam)
3839
* [Tracer](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/tracing/examples)
3940
* [Logger](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/logger/examples)
4041
* [Metrics](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/metrics/examples)

Diff for: packages/tracer/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
A suite of TypeScript utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, and more. (AWS Lambda Powertools for [Python](https://github.com/awslabs/aws-lambda-powertools-python) and AWS Lambda Powertools for [Java](https://github.com/awslabs/aws-lambda-powertools-java) are also available).
99

10-
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)**
10+
**[📜 Documentation](https://awslabs.github.io/aws-lambda-powertools-typescript/)** | **[NPM](https://www.npmjs.com/org/aws-lambda-powertools)** | **[Roadmap](https://github.com/awslabs/aws-lambda-powertools-roadmap/projects/1)** | **[Examples](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples)**
1111

1212
> **An AWS Developer Acceleration (DevAx) initiative by Specialist Solution Architects | [email protected]**
1313
@@ -35,6 +35,7 @@ Each TypeScript utility is installed as standalone NPM package.
3535
### Examples
3636

3737
* [CDK](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/cdk)
38+
* [SAM](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/examples/sam)
3839
* [Tracer](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/tracing/examples)
3940
* [Logger](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/logger/examples)
4041
* [Metrics](https://github.com/awslabs/aws-lambda-powertools-typescript/tree/main/packages/metrics/examples)

0 commit comments

Comments
 (0)