Skip to content

Commit 4ef2292

Browse files
committed
fix quote
1 parent 674164f commit 4ef2292

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

packages/aws-cdk-lib/aws-synthetics/README.md

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,49 @@ Amazon CloudWatch Synthetics allow you to monitor your application by generating
77
To illustrate how to use a canary, assume your application defines the following endpoint:
88

99
```console
10-
% curl "https://api.example.com/user/books/topbook/"
10+
% curl 'https://api.example.com/user/books/topbook/'
1111
The Hitchhikers Guide to the Galaxy
1212
```
1313

1414
The below code defines a canary that will hit the `books/topbook` endpoint every 5 minutes:
1515

1616
```ts
17-
const canary = new synthetics.Canary(this, "MyCanary", {
17+
const canary = new synthetics.Canary(this, 'MyCanary', {
1818
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
1919
test: synthetics.Test.custom({
20-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
21-
handler: "index.handler",
20+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
21+
handler: 'index.handler',
2222
}),
2323
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
2424
environmentVariables: {
25-
stage: "prod",
25+
stage: 'prod',
2626
},
2727
});
2828
```
2929

3030
The following is an example of an `index.js` file which exports the `handler` function:
3131

3232
```js
33-
const synthetics = require("Synthetics");
34-
const log = require("SyntheticsLogger");
33+
const synthetics = require('Synthetics');
34+
const log = require('SyntheticsLogger');
3535

3636
const pageLoadBlueprint = async function () {
3737
// Configure the stage of the API using environment variables
3838
const url = `https://api.example.com/${process.env.stage}/user/books/topbook/`;
3939

4040
const page = await synthetics.getPage();
4141
const response = await page.goto(url, {
42-
waitUntil: "domcontentloaded",
42+
waitUntil: 'domcontentloaded',
4343
timeout: 30000,
4444
});
4545
// Wait for page to render. Increase or decrease wait time based on endpoint being monitored.
4646
await page.waitFor(15000);
4747
// This will take a screenshot that will be included in test output artifacts.
48-
await synthetics.takeScreenshot("loaded", "loaded");
48+
await synthetics.takeScreenshot('loaded', 'loaded');
4949
const pageTitle = await page.title();
50-
log.info("Page title: " + pageTitle);
50+
log.info('Page title: ' + pageTitle);
5151
if (response.status() !== 200) {
52-
throw "Failed to load page!";
52+
throw 'Failed to load page!';
5353
}
5454
};
5555

@@ -84,7 +84,7 @@ You can also specify a [cron expression](https://docs.aws.amazon.com/AmazonCloud
8484

8585
```ts
8686
const schedule = synthetics.Schedule.cron({
87-
hour: "0,8,16", // Run at 12am, 8am, 4pm UTC every day
87+
hour: '0,8,16', // Run at 12am, 8am, 4pm UTC every day
8888
});
8989
```
9090

@@ -101,11 +101,11 @@ Max retries can be set between 0 and 2. Canaries which time out after 10 minutes
101101
For more information, see [Configuring your canary to retry automatically](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_autoretry.html).
102102

103103
```ts
104-
const canary = new synthetics.Canary(this, "MyCanary", {
104+
const canary = new synthetics.Canary(this, 'MyCanary', {
105105
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
106106
test: synthetics.Test.custom({
107-
handler: "canary.handler",
108-
code: synthetics.Code.fromAsset(path.join(__dirname, "canaries")),
107+
handler: 'canary.handler',
108+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canaries')),
109109
}),
110110
runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_5_1,
111111
maxRetries: 2, // The canary run will retry up to 2 times on a failure
@@ -121,11 +121,11 @@ With tracing enabled, traces are sent for all calls made by the canary that use
121121
For more information, see [Canaries and X-Ray tracing](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html).
122122

123123
```ts
124-
const canary = new synthetics.Canary(this, "MyCanary", {
124+
const canary = new synthetics.Canary(this, 'MyCanary', {
125125
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
126126
test: synthetics.Test.custom({
127-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
128-
handler: "index.handler",
127+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
128+
handler: 'index.handler',
129129
}),
130130
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
131131
activeTracing: true, // active tracing enabled
@@ -137,13 +137,13 @@ const canary = new synthetics.Canary(this, "MyCanary", {
137137
You can set the maximum amount of memory the canary can use while running with the `memory` property.
138138

139139
```ts
140-
import * as cdk from "aws-cdk-lib";
140+
import * as cdk from 'aws-cdk-lib';
141141

142-
const canary = new synthetics.Canary(this, "MyCanary", {
142+
const canary = new synthetics.Canary(this, 'MyCanary', {
143143
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
144144
test: synthetics.Test.custom({
145-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
146-
handler: "index.handler",
145+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
146+
handler: 'index.handler',
147147
}),
148148
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
149149
memory: cdk.Size.mebibytes(1024), // 1024 MiB
@@ -155,13 +155,13 @@ const canary = new synthetics.Canary(this, "MyCanary", {
155155
You can set how long the canary is allowed to run before it must stop with the `timeout` property.
156156

157157
```ts
158-
import * as cdk from "aws-cdk-lib";
158+
import * as cdk from 'aws-cdk-lib';
159159

160-
const canary = new synthetics.Canary(this, "MyCanary", {
160+
const canary = new synthetics.Canary(this, 'MyCanary', {
161161
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
162162
test: synthetics.Test.custom({
163-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
164-
handler: "index.handler",
163+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
164+
handler: 'index.handler',
165165
}),
166166
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
167167
timeout: cdk.Duration.seconds(60), // 60 seconds
@@ -180,11 +180,11 @@ Available browser types:
180180
You can specify up to 2 browser configurations. When multiple browsers are configured, the canary will run tests on each browser sequentially.
181181

182182
```ts
183-
const canary = new synthetics.Canary(this, "MyCanary", {
183+
const canary = new synthetics.Canary(this, 'MyCanary', {
184184
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
185185
test: synthetics.Test.custom({
186-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
187-
handler: "index.handler",
186+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
187+
handler: 'index.handler',
188188
}),
189189
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_9_1,
190190
browserConfigs: [
@@ -212,10 +212,10 @@ In the CDK, you can configure your canary to delete the underlying lambda functi
212212
This can be provisioned by setting `provisionedResourceCleanup` to `true`.
213213

214214
```ts
215-
const canary = new synthetics.Canary(this, "Canary", {
215+
const canary = new synthetics.Canary(this, 'Canary', {
216216
test: synthetics.Test.custom({
217-
handler: "index.handler",
218-
code: synthetics.Code.fromInline("/* Synthetics handler code"),
217+
handler: 'index.handler',
218+
code: synthetics.Code.fromInline('/* Synthetics handler code'),
219219
}),
220220
provisionedResourceCleanup: true,
221221
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
@@ -241,30 +241,30 @@ Using the `Code` class static initializers:
241241

242242
```ts
243243
// To supply the code inline:
244-
new synthetics.Canary(this, "Inline Canary", {
244+
new synthetics.Canary(this, 'Inline Canary', {
245245
test: synthetics.Test.custom({
246-
code: synthetics.Code.fromInline("/* Synthetics handler code */"),
247-
handler: "index.handler", // must be 'index.handler'
246+
code: synthetics.Code.fromInline('/* Synthetics handler code */'),
247+
handler: 'index.handler', // must be 'index.handler'
248248
}),
249249
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
250250
});
251251

252252
// To supply the code from your local filesystem:
253-
new synthetics.Canary(this, "Asset Canary", {
253+
new synthetics.Canary(this, 'Asset Canary', {
254254
test: synthetics.Test.custom({
255-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
256-
handler: "index.handler", // must end with '.handler'
255+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
256+
handler: 'index.handler', // must end with '.handler'
257257
}),
258258
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
259259
});
260260

261261
// To supply the code from a S3 bucket:
262-
import * as s3 from "aws-cdk-lib/aws-s3";
263-
const bucket = new s3.Bucket(this, "Code Bucket");
264-
new synthetics.Canary(this, "Bucket Canary", {
262+
import * as s3 from 'aws-cdk-lib/aws-s3';
263+
const bucket = new s3.Bucket(this, 'Code Bucket');
264+
new synthetics.Canary(this, 'Bucket Canary', {
265265
test: synthetics.Test.custom({
266-
code: synthetics.Code.fromBucket(bucket, "canary.zip"),
267-
handler: "index.handler", // must end with '.handler'
266+
code: synthetics.Code.fromBucket(bucket, 'canary.zip'),
267+
handler: 'index.handler', // must end with '.handler'
268268
}),
269269
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
270270
});
@@ -310,13 +310,13 @@ This can allow for monitoring services that may be internal to a specific VPC. T
310310
This will automatically attach the appropriate IAM permissions to attach to the VPC. This will also create a Security Group and attach to the default subnets for the VPC unless specified via `vpcSubnets` and `securityGroups`.
311311
312312
```ts
313-
import * as ec2 from "aws-cdk-lib/aws-ec2";
313+
import * as ec2 from 'aws-cdk-lib/aws-ec2';
314314
315315
declare const vpc: ec2.IVpc;
316-
new synthetics.Canary(this, "Vpc Canary", {
316+
new synthetics.Canary(this, 'Vpc Canary', {
317317
test: synthetics.Test.custom({
318-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
319-
handler: "index.handler",
318+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
319+
handler: 'index.handler',
320320
}),
321321
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
322322
vpc,
@@ -340,10 +340,10 @@ You can configure a CloudWatch Alarm on a canary metric. Metrics are emitted by
340340
Create an alarm that tracks the canary metric:
341341

342342
```ts
343-
import * as cloudwatch from "aws-cdk-lib/aws-cloudwatch";
343+
import * as cloudwatch from 'aws-cdk-lib/aws-cloudwatch';
344344

345345
declare const canary: synthetics.Canary;
346-
new cloudwatch.Alarm(this, "CanaryAlarm", {
346+
new cloudwatch.Alarm(this, 'CanaryAlarm', {
347347
metric: canary.metricSuccessPercent(),
348348
evaluationPeriods: 2,
349349
threshold: 90,
@@ -361,11 +361,11 @@ If the dry run succeeds, the canary will be updated with the changes.
361361
If the dry run fails, the CloudFormation deployment will fail with the dry run's failure reason.
362362

363363
```ts
364-
const canary = new synthetics.Canary(this, "MyCanary", {
364+
const canary = new synthetics.Canary(this, 'MyCanary', {
365365
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
366366
test: synthetics.Test.custom({
367-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
368-
handler: "index.handler",
367+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
368+
handler: 'index.handler',
369369
}),
370370
runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_5_1,
371371
dryRunAndUpdate: true, // Enable dry run before updating
@@ -382,11 +382,11 @@ one will be auto-generated when the canary is created. You may add
382382
to the auto-generated bucket.
383383

384384
```ts
385-
const canary = new synthetics.Canary(this, "MyCanary", {
385+
const canary = new synthetics.Canary(this, 'MyCanary', {
386386
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
387387
test: synthetics.Test.custom({
388-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
389-
handler: "index.handler",
388+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
389+
handler: 'index.handler',
390390
}),
391391
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
392392
artifactsBucketLifecycleRules: [
@@ -404,15 +404,15 @@ You can choose the encryption options SSE-S3 or SSE-KMS by setting the `artifact
404404
When you use SSE-KMS, you can also supply your own external KMS key by specifying the `kmsKey` property. If you don't, a KMS key will be automatically created and associated with the canary.
405405

406406
```ts
407-
import * as kms from "aws-cdk-lib/aws-kms";
407+
import * as kms from 'aws-cdk-lib/aws-kms';
408408

409-
const key = new kms.Key(this, "myKey");
409+
const key = new kms.Key(this, 'myKey');
410410

411-
const canary = new synthetics.Canary(this, "MyCanary", {
411+
const canary = new synthetics.Canary(this, 'MyCanary', {
412412
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
413413
test: synthetics.Test.custom({
414-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
415-
handler: "index.handler",
414+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
415+
handler: 'index.handler',
416416
}),
417417
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0,
418418
artifactsBucketLifecycleRules: [
@@ -430,11 +430,11 @@ const canary = new synthetics.Canary(this, "MyCanary", {
430430
You can configure a canary to replicate its tags to the underlying Lambda function. This is useful when you want the same tags that are applied to the canary to also be applied to the Lambda function that the canary uses.
431431

432432
```ts
433-
const canary = new synthetics.Canary(this, "MyCanary", {
433+
const canary = new synthetics.Canary(this, 'MyCanary', {
434434
schedule: synthetics.Schedule.rate(Duration.minutes(5)),
435435
test: synthetics.Test.custom({
436-
code: synthetics.Code.fromAsset(path.join(__dirname, "canary")),
437-
handler: "index.handler",
436+
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
437+
handler: 'index.handler',
438438
}),
439439
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0,
440440
resourcesToReplicateTags: [
@@ -460,8 +460,8 @@ You can create a group and associate canaries with it:
460460
declare const canary1: synthetics.Canary;
461461
declare const canary2: synthetics.Canary;
462462

463-
const group = new synthetics.Group(this, "MyCanaryGroup", {
464-
groupName: "production-canaries",
463+
const group = new synthetics.Group(this, 'MyCanaryGroup', {
464+
groupName: 'production-canaries',
465465
canaries: [canary1, canary2],
466466
});
467467
```
@@ -473,7 +473,7 @@ You can add canaries to a group after creation:
473473
```ts
474474
declare const canary: synthetics.Canary;
475475

476-
const group = new synthetics.Group(this, "MyCanaryGroup");
476+
const group = new synthetics.Group(this, 'MyCanaryGroup');
477477

478478
// Add canary to group
479479
group.addCanary(canary);
@@ -493,15 +493,15 @@ You can import existing groups by ARN or name:
493493
// Import by ARN
494494
const importedGroup = synthetics.Group.fromGroupArn(
495495
this,
496-
"ImportedGroup",
497-
"arn:aws:synthetics:us-east-1:123456789012:group:my-group"
496+
'ImportedGroup',
497+
'arn:aws:synthetics:us-east-1:123456789012:group:my-group'
498498
);
499499

500500
// Import by name
501501
const importedGroup = synthetics.Group.fromGroupName(
502502
this,
503-
"ImportedGroup",
504-
"my-group"
503+
'ImportedGroup',
504+
'my-group'
505505
);
506506
```
507507

0 commit comments

Comments
 (0)