Skip to content

Commit 9de85ef

Browse files
author
Michael Brewer
committed
Merge branch 'main' into fix-doc-examples
2 parents 8658e2d + cf6af25 commit 9de85ef

30 files changed

+7275
-17336
lines changed

Diff for: .github/workflows/on-push.yml renamed to .github/workflows/pr_lint_and_test.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
name: on-push-event
1+
name: pr-lint-and-test
22
on:
3-
push:
4-
branches:
5-
- '**' # matches every branch
6-
- '!main'
3+
pull_request:
4+
types: [opened, synchronize]
75
jobs:
86
on_push:
97
runs-on: ubuntu-latest
@@ -45,4 +43,4 @@ jobs:
4543
uses: romeovs/[email protected]
4644
with:
4745
github-token: ${{ secrets.GITHUB_TOKEN }}
48-
lcov-file: ./coverage/lcov.info
46+
lcov-file: ./coverage/lcov.info

Diff for: .github/workflows/run-e2e-tests.yml

+6
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ jobs:
2828
aws-region: eu-west-1
2929
- name: Run integration tests
3030
run: npm run lerna-test:e2e
31+
- name: Test packaging
32+
run: |
33+
npm run lerna-package
34+
cd examples/cdk
35+
npm install ../../packages/**/dist/aws-lambda-powertools-*
36+
npm run test

Diff for: CONTRIBUTING.md

+23
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,29 @@ You can run the end-to-end tests automatically on your forked project by followi
152152

153153
> :warning: **Don't automatically run end-to-end tests on branch push or PRs**. A malicious attacker can submit a pull request to attack your AWS account. Ideally, use a blank account without any important workload/data, and limit `AWS_ROLE_ARN_TO_ASSUME` permission to least minimum privilege.
154154
155+
### Examples
156+
157+
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.
158+
159+
To test your updates with these examples you just have to:
160+
161+
1. Build your local version of *aws-lambda-powertools-typescript* npm packages with `npm run lerna-package`
162+
2. Update their references in examples
163+
```
164+
cd examples/cdk
165+
npm install ../../packages/**/dist/aws-lambda-powertools-*
166+
```
167+
3. Run cdk tests
168+
```
169+
npm run test
170+
```
171+
4. Deploy
172+
```
173+
npm run cdk deploy
174+
```
175+
176+
Previous command will deploy AWS resources therefore you will need an AWS account and it might incur in 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/).
177+
155178
### Conventions
156179
157180
Category | Convention

Diff for: docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ AWS Lambda Powertools TypeScript provides a suite of utilities for AWS Lambda fu
1414

1515
## Tenets
1616

17-
This project separates core utilities that will be available in other runtimes vs general utilities that might not be available across all runtimes.
17+
Core utilities such as Tracer, Logger, Metrics, and Event Handler will be available across all Lambda Powertools runtimes. Additional utilities are subjective to each language ecosystem and customer demand.
1818

1919
* **AWS Lambda only**. We optimise for AWS Lambda function environments and supported runtimes only. Utilities might work with web frameworks and non-Lambda environments, though they are not officially supported.
2020
* **Eases the adoption of best practices**. The main priority of the utilities is to facilitate best practices adoption, as defined in the AWS Well-Architected Serverless Lens; all other functionality is optional.

Diff for: examples/cdk/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ This is a deployable CDK app that deploys AWS Lambda functions as part of a Clou
44

55
You will need to have a valid AWS Account in order to deploy these resources. These resources may incur costs to your AWS Account. The cost from **some services** are 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) but not all of them. 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/).
66

7-
The example functions, located in the `lib` folder, are invoked automatically, twice, when deployed using the CDK construct defined in `lib/example-function.ts`. The first invocation demonstrates the effect on logs/metrics/annotations when the Lambda function has a cold start, and the latter without a cold start.
7+
The example functions, located in the `src` folder, are invoked automatically, twice, when deployed using the CDK construct defined in `src/example-function.ts`. The first invocation demonstrates the effect on logs/metrics/annotations when the Lambda function has a cold start, and the latter without a cold start.
88

99
## Deploying the stack
1010

11-
* Ensure that CDK v2 is installed globally on your machine (if not, run `npm install -g aws-cdk`)
1211
* Navigate to this location of the repo in your terminal (`examples/cdk`)
1312
* `npm install`
14-
* `cdk deploy --all --profile <YOUR_AWS_PROFILE>`
13+
* `npm run cdk deploy --all --profile <YOUR_AWS_PROFILE>`
1514

1615
Note: Prior to deploying you may need to run `cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` if you have not already bootstrapped your account for CDK.
1716

Diff for: examples/cdk/bin/cdk-app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22
import 'source-map-support/register';
33
import * as cdk from 'aws-cdk-lib';
4-
import { CdkAppStack } from '../lib/example-stack';
4+
import { CdkAppStack } from '../src/example-stack';
55

66
const app = new cdk.App();
77
new CdkAppStack(app, 'LambdaPowertoolsTypeScript-ExamplesCdkStack', {});

Diff for: examples/cdk/jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
testEnvironment: 'node',
3-
roots: ['<rootDir>/test'],
3+
roots: ['<rootDir>/tests'],
44
testMatch: ['**/*.test.ts'],
55
transform: {
66
'^.+\\.tsx?$': 'ts-jest'

0 commit comments

Comments
 (0)