Skip to content

Commit 669bbcc

Browse files
committed
chore: removed sam folder & merged samples
1 parent 36c6748 commit 669bbcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+327
-1609
lines changed

.github/boring-cyborg.yml

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,7 @@ labelPRBasedOnFilePath:
7171
- docs/**/*
7272
- mkdocs.yml
7373
- typedoc.js
74-
- examples/cdk/bin/*
75-
- examples/cdk/functions/*
76-
- examples/cdk/functions/**/*
77-
- examples/cdk/src/*
78-
- examples/cdk/src/**/*
79-
- examples/cdk/tests/*
80-
- examples/cdk/tests/**/*
81-
- examples/cdk/README.md
82-
- examples/cdk/cdk.json
83-
- examples/sam/events/*
84-
- examples/sam/src/*
85-
- examples/sam/src/**/*
86-
- examples/sam/tests/*
87-
- examples/sam/tests/**/*
88-
- examples/sam/README.md
89-
- examples/sam/template.yaml
74+
- examples/app/*
9075

9176
area/automation:
9277
- .github/scripts/*
@@ -137,8 +122,7 @@ labelPRBasedOnFilePath:
137122
- packages/parser/README.md
138123
- layers/tsconfig*.json
139124
- layers/README.md
140-
- examples/sam/tsconfig*.json
141-
- examples/cdk/tsconfig*.json
125+
- examples/app/tsconfig*.json
142126

143127
type/dependencies:
144128
- package.json
@@ -153,8 +137,7 @@ labelPRBasedOnFilePath:
153137
- packages/validator/package.json
154138
- packages/batch/package.json
155139
- layers/package.json
156-
- examples/cdk/package.json
157-
- examples/sam/package.json
140+
- examples/app/package.json
158141

159142
##### Greetings ########################################################################################################
160143
firstPRWelcomeComment: >

.github/workflows/reusable-run-linting-check-and-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
NODE_ENV: dev
3838
strategy:
3939
matrix:
40-
example: ["sam", "cdk"]
40+
example: ["app"]
4141
fail-fast: false
4242
defaults:
4343
run:

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ site
4141
# Generated API documentation (from TypeDoc)
4242
/api
4343

44-
# SAM Example copies files
45-
/examples/sam/src/handlers/*
46-
!/examples/sam/src/handlers/COPY_LAMBDA_FUNCTIONS_HERE
47-
4844
# Layer temp files
4945
tmp
5046

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ Or refer to the installation guide of each utility:
8484

8585
### Examples
8686

87-
* [CDK](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/cdk)
88-
* [SAM](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/sam)
87+
You can find examples of how to use Powertools for AWS Lambda (TypeScript) in the [examples](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/app) directory. The application is a simple REST API that can be deployed via either AWS CDK or AWS SAM.
8988

9089
### Demo applications
9190

docs/contributing/conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Whenever possible, we use the same directory structure for all utilities. This m
3131
There are also a few other workspaces that are not utilities published to npm, but that still share dependencies and/or runtime code with the utilities. These workspaces are:
3232

3333
* `docs/snippets`: contains the documentation code snippets
34-
* `examples/*`: contains the example projects deployed via AWS CDK or AWS SAM
34+
* `examples/app`: contains an example project that can be deployed via AWS CDK or AWS SAM
3535
* `layers`: contains the code used to build and publish the [Lambda layers](../index.md#lambda-layer)
3636

3737
## Testing definition

docs/index.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,9 @@ The examples in this documentation will feature all the approaches described abo
272272

273273
## Examples
274274

275-
The project's repository includes examples of how to instrument your functions both in AWS CDK and AWS SAM:
275+
You can find examples of how to use Powertools for AWS Lambda (TypeScript) in the [examples](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/app){target="_blank"} directory. The application is a simple REST API that can be deployed via either AWS CDK or AWS SAM.
276276

277-
* [AWS CDK](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/cdk){target="_blank"}
278-
* [AWS SAM](https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/examples/sam){target="_blank"}
279-
280-
If instead you want to see Powertools for AWS Lambda (TypeScript) in a slightly more complex use case, check the [Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo) or the [AWS Lambda performance tuning](https://github.com/aws-samples/optimizations-for-lambda-functions) repository. Both demos use Powertools for AWS Lambda (TypeScript) as well as demonstrating other common techniques for Lambda functions written in TypeScript.
277+
If instead you want to see Powertools for AWS Lambda (TypeScript) in slightly different use cases, check the [Serverless TypeScript Demo](https://github.com/aws-samples/serverless-typescript-demo) or the [AWS Lambda performance tuning](https://github.com/aws-samples/optimizations-for-lambda-functions) repository. Both demos use Powertools for AWS Lambda (TypeScript) as well as demonstrating other common techniques for Lambda functions written in TypeScript.
281278

282279

283280
## Features

examples/cdk/.gitignore renamed to examples/app/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,13 @@ node_modules
88
.cdk.staging
99
cdk.out
1010
lib
11+
# npm lock file - this is managed by the npm workspace
12+
package-lock.json
13+
14+
**/.aws-sam
15+
16+
# SAM
17+
samconfig.toml
18+
1119
# npm lock file - this is managed by the npm workspace
1220
package-lock.json
File renamed without changes.
File renamed without changes.

examples/cdk/cdk.json renamed to examples/app/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"app": "tsx bin/cdk-app.ts",
2+
"app": "tsx cdk/example-app.ts",
33
"watch": {
44
"include": [
55
"**"

examples/app/cdk/example-app.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
import 'source-map-support/register';
3+
import { App } from 'aws-cdk-lib';
4+
import { PowertoolsExampleStack } from './example-stack.js';
5+
6+
const app = new App();
7+
new PowertoolsExampleStack(app, 'PowertoolsTypeScript-Example-CDK', {});

examples/cdk/src/example-stack.ts renamed to examples/app/cdk/example-stack.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { StringParameter } from 'aws-cdk-lib/aws-ssm';
2121
import { Construct } from 'constructs';
2222
import { FunctionWithLogGroup } from './function-with-logstream-construct.js';
2323

24-
export class CdkAppStack extends Stack {
24+
export class PowertoolsExampleStack extends Stack {
2525
public constructor(scope: Construct, id: string, props?: StackProps) {
2626
super(scope, id, props);
2727

@@ -49,7 +49,7 @@ export class CdkAppStack extends Stack {
4949

5050
// Idempotency table
5151
const idempotencyTable = new Table(this, 'idempotencyTable', {
52-
tableName: 'powertools-example-idempotency-table',
52+
tableName: 'powertools-example-idempotency',
5353
partitionKey: {
5454
name: 'id',
5555
type: AttributeType.STRING,
@@ -58,10 +58,11 @@ export class CdkAppStack extends Stack {
5858
billingMode: BillingMode.PAY_PER_REQUEST,
5959
removalPolicy: RemovalPolicy.DESTROY, // for demo only, change to RETAIN in production
6060
});
61+
6162
/**
6263
* We will store the idempotency table name in a SSM parameter to simulate a potential
63-
* cross-stack reference. This is not necessary in this example, but it's a good way of showing
64-
* how to use SSM parameters to store and retrieve it from the function.
64+
* cross-stack reference. This is not strictly necessary in this example, but it's a good way of showing
65+
* how to use SSM parameters and retrieve them using Powertools.
6566
*/
6667
const idempotencyTableNameParam = new StringParameter(
6768
this,
@@ -146,7 +147,7 @@ export class CdkAppStack extends Stack {
146147

147148
/**
148149
* In this examle, we emit a CommonJS (CJS) bundle and include all the
149-
* dependencies in the bundle.
150+
* dependencies in it.
150151
*/
151152
const getByIdFn = new FunctionWithLogGroup(this, 'get-by-id-fn', {
152153
entry: './functions/get-by-id.ts',
File renamed without changes.

examples/cdk/package.json renamed to examples/app/package.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"private": true,
99
"description": "This project contains source code and supporting files for a serverless application that you can deploy with CDK.",
1010
"license": "MIT-0",
11-
"bin": {
12-
"cdk-app": "bin/cdk-app.js"
13-
},
1411
"scripts": {
1512
"build": "echo 'Not applicable, run `npx cdk synth` instead to build the stack'",
1613
"test": "npm run test:unit",
@@ -35,28 +32,25 @@
3532
"#errors": "./functions/commons/errors.js"
3633
},
3734
"devDependencies": {
38-
"@aws-lambda-powertools/commons": "^2.0.3",
39-
"@aws-lambda-powertools/logger": "^2.0.3",
40-
"@aws-lambda-powertools/metrics": "^2.0.3",
41-
"@aws-lambda-powertools/parameters": "^2.0.3",
42-
"@aws-lambda-powertools/tracer": "^2.0.3",
43-
"@aws-sdk/client-ssm": "^3.533.0",
44-
"@aws-sdk/lib-dynamodb": "^3.533.0",
4535
"@types/aws-lambda": "^8.10.136",
4636
"@types/node": "20.11.28",
4737
"aws-cdk": "^2.133.0",
38+
"aws-cdk-lib": "^2.133.0",
4839
"constructs": "^10.3.0",
49-
"esbuild": "^0.20.2",
40+
"source-map-support": "^0.5.21",
5041
"tsx": "^4.7.1",
5142
"typescript": "^5.4.2"
5243
},
5344
"dependencies": {
5445
"@aws-lambda-powertools/batch": "^2.0.2",
5546
"@aws-lambda-powertools/idempotency": "^2.0.2",
47+
"@aws-lambda-powertools/logger": "^2.0.3",
48+
"@aws-lambda-powertools/metrics": "^2.0.3",
49+
"@aws-lambda-powertools/parameters": "^2.0.3",
50+
"@aws-lambda-powertools/tracer": "^2.0.3",
51+
"@aws-sdk/client-ssm": "^3.533.0",
52+
"@aws-sdk/lib-dynamodb": "^3.533.0",
5653
"@middy/core": "^4.7.0",
57-
"aws-cdk-lib": "^2.133.0",
58-
"construct": "^1.0.0",
59-
"phin": "^3.7.0",
60-
"source-map-support": "^0.5.21"
54+
"esbuild": "^0.20.2"
6155
}
6256
}

0 commit comments

Comments
 (0)