Skip to content

Commit de85af3

Browse files
committed
Improve examples/cdk/README.md
1 parent 40655ea commit de85af3

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

examples/cdk/README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
# Welcome to your CDK TypeScript project!
1+
# AWS Lambda Powertools (TypeScript) examples in CDK
22

3-
This is a blank project for TypeScript development with CDK.
3+
This is a deployable CDK app that deploys AWS Lambda functions as part of a CloudFormation stack. These Lambda functions use the utilities made available as part of AWS Lambda Powertools (TypeScript) to demonstrate their usage.
44

5-
The `cdk.json` file tells the CDK Toolkit how to execute your app.
5+
The example functions, located in the `lib` folder, are triggered automatically when deployed using the CDK construct defined in `lib/example-function.ts`.
66

7-
## Useful commands
7+
## Deploying the stack
88

9-
* `npm run build` compile typescript to js
10-
* `npm run watch` watch for changes and compile
11-
* `npm run test` perform the jest unit tests
12-
* `cdk deploy` deploy this stack to your default AWS account/region
13-
* `cdk diff` compare deployed stack with current state
14-
* `cdk synth` emits the synthesized CloudFormation template
9+
* Navigate to this location of the repo in your terminal (`examples/cdk`)
10+
* `npm install`
11+
* `npx cdk deploy --all --profile <YOUR_AWS_PROFILE>`
12+
13+
Note: Prior to deploying you may need to run `npx cdk bootstrap aws://<YOU_AWS_ACCOUNT_ID>/<AWS_REGION> --profile <YOUR_AWS_PROFILE>` if you have not already bootstrapped your account for CDK.
14+
15+
## Viewing Utility Outputs
16+
17+
All utility outputs can be viewed from the CloudWatch console.
18+
19+
* `Logger` outputs to Logs > Log groups
20+
* `Metrics` outputs to Metrics > All metrics > LambdaPowertoolsTypeScript-CDKExample
21+
* `Tracer` outputs to X-Ray traces > Traces

examples/cdk/bin/cdk-app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import * as cdk from 'aws-cdk-lib';
44
import { CdkAppStack } from '../lib/example-stack';
55

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

packages/metrics/src/Metrics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class Metrics implements MetricsInterface {
210210
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
211211
* import { Callback, Context } from 'aws-lambda';
212212
*
213-
* const metrics = new Metrics({namespace:"CDKExample", serviceName:"withDecorator"});
213+
* const metrics = new Metrics({namespace:"LambdaPowertoolsTypeScript-CDKExample", serviceName:"withDecorator"});
214214
*
215215
* export class MyFunctionWithDecorator {
216216
*
@@ -267,7 +267,7 @@ class Metrics implements MetricsInterface {
267267
* ```typescript
268268
* import { Metrics, MetricUnits } from '@aws-lambda-powertools/metrics';
269269
*
270-
* const metrics = new Metrics({namespace: "CDKExample", serviceName: "MyFunction"}); // Sets metric namespace, and service as a metric dimension
270+
* const metrics = new Metrics({namespace: "LambdaPowertoolsTypeScript-CDKExample", serviceName: "MyFunction"}); // Sets metric namespace, and service as a metric dimension
271271
*
272272
* export const handler = async (_event: any, _context: any) => {
273273
* metrics.addMetric('test-metric', MetricUnits.Count, 10);

packages/metrics/tests/e2e/decorator.test.MyFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Metrics, MetricUnits } from '../../src';
22
import { Context } from 'aws-lambda';
33
import { LambdaInterface } from '../../examples/utils/lambda/LambdaInterface';
44

5-
const namespace = process.env.EXPECTED_NAMESPACE ?? 'CDKExample';
5+
const namespace = process.env.EXPECTED_NAMESPACE ?? 'LambdaPowertoolsTypeScript-CDKExample';
66
const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandardHandler';
77
const metricName = process.env.EXPECTED_METRIC_NAME ?? 'MyMetric';
88
const metricUnit = (process.env.EXPECTED_METRIC_UNIT as MetricUnits) ?? MetricUnits.Count;

packages/metrics/tests/e2e/standardFunctions.test.MyFunction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Metrics, MetricUnits } from '../../src';
22
import { Context } from 'aws-lambda';
33

4-
const namespace = process.env.EXPECTED_NAMESPACE ?? 'CDKExample';
4+
const namespace = process.env.EXPECTED_NAMESPACE ?? 'LambdaPowertoolsTypeScript-CDKExample';
55
const serviceName = process.env.EXPECTED_SERVICE_NAME ?? 'MyFunctionWithStandardHandler';
66
const metricName = process.env.EXPECTED_METRIC_NAME ?? 'MyMetric';
77
const metricUnit = (process.env.EXPECTED_METRIC_UNIT as MetricUnits) ?? MetricUnits.Count;

0 commit comments

Comments
 (0)