Skip to content

Commit 1d7a9a8

Browse files
authored
feat(synthetics): support runtime nodejs puppeteer 4.0 (#25553)
## What change Add CloudWatch Synthetics runtime nodejs puppeteer 4.0. ## Others I changed integ test to using integ-tests assertions. Closes #25493 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent fec928e commit 1d7a9a8

File tree

19 files changed

+5562
-928
lines changed

19 files changed

+5562
-928
lines changed

packages/@aws-cdk/aws-synthetics-alpha/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const canary = new synthetics.Canary(this, 'MyCanary', {
3636
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
3737
handler: 'index.handler',
3838
}),
39-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
39+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
4040
environmentVariables: {
4141
stage: 'prod',
4242
},
@@ -120,7 +120,7 @@ const canary = new synthetics.Canary(stack, 'Canary', {
120120
code: synthetics.Code.fromInline('/* Synthetics handler code'),
121121
}),
122122
enableAutoDeleteLambdas: true,
123-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
123+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
124124
});
125125
```
126126

@@ -146,7 +146,7 @@ new synthetics.Canary(this, 'Inline Canary', {
146146
code: synthetics.Code.fromInline('/* Synthetics handler code */'),
147147
handler: 'index.handler', // must be 'index.handler'
148148
}),
149-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
149+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
150150
});
151151

152152
// To supply the code from your local filesystem:
@@ -155,7 +155,7 @@ new synthetics.Canary(this, 'Asset Canary', {
155155
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
156156
handler: 'index.handler', // must end with '.handler'
157157
}),
158-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
158+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
159159
});
160160

161161
// To supply the code from a S3 bucket:
@@ -166,7 +166,7 @@ new synthetics.Canary(this, 'Bucket Canary', {
166166
code: synthetics.Code.fromBucket(bucket, 'canary.zip'),
167167
handler: 'index.handler', // must end with '.handler'
168168
}),
169-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
169+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
170170
});
171171
```
172172

@@ -205,7 +205,7 @@ new synthetics.Canary(this, 'Vpc Canary', {
205205
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
206206
handler: 'index.handler',
207207
}),
208-
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
208+
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
209209
vpc,
210210
});
211211
```

packages/@aws-cdk/aws-synthetics-alpha/lib/runtime.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ export class Runtime {
203203
*/
204204
public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_9 = new Runtime('syn-nodejs-puppeteer-3.9', RuntimeFamily.NODEJS);
205205

206+
/**
207+
* `syn-nodejs-puppeteer-4.0` includes the following:
208+
* - Lambda runtime Node.js 16.x
209+
* - Puppeteer-core version 5.5.0
210+
* - Chromium version 92.0.4512
211+
*
212+
* New Features:
213+
* - **Dependency upgrades**: The Node.js dependency is updated to 16.x.
214+
*
215+
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-4.0
216+
*/
217+
public static readonly SYNTHETICS_NODEJS_PUPPETEER_4_0 = new Runtime('syn-nodejs-puppeteer-4.0', RuntimeFamily.NODEJS);
218+
206219
/**
207220
* `syn-python-selenium-1.0` includes the following:
208221
* - Lambda runtime Python 3.8

packages/@aws-cdk/aws-synthetics-alpha/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"@aws-cdk/integ-runner": "0.0.0",
8888
"@aws-cdk/cfn2ts": "0.0.0",
8989
"@aws-cdk/pkglint": "0.0.0",
90+
"@aws-cdk/integ-tests-alpha": "0.0.0",
9091
"@types/jest": "^29.5.1",
9192
"jest": "^29.5.0",
9293
"aws-cdk-lib": "0.0.0",

packages/@aws-cdk/aws-synthetics-alpha/test/canaries/nodejs/node_modules/canary.js

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-synthetics-alpha/test/canaries/python/canary.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# This example comes from the AWS Synthetics service console "API canary" blueprint
22

3+
import os
34
import json
45
import http.client
56
import urllib.parse
@@ -23,7 +24,7 @@ def verify_request(method, url, post_data=None, headers={}):
2324
else:
2425
conn = http.client.HTTPConnection(parsed_url.hostname, parsed_url.port)
2526

26-
conn.request(method, url, str(post_data), headers)
27+
conn.request(method, url, post_data, headers)
2728
response = conn.getresponse()
2829
logger.info("Status Code: %s " % response.status)
2930
logger.info("Response Headers: %s" % json.dumps(response.headers.as_string()))
@@ -46,7 +47,7 @@ def verify_request(method, url, post_data=None, headers={}):
4647

4748
def main():
4849

49-
url = 'https://example.com/'
50+
url = os.environ['URL']
5051
method = 'GET'
5152
postData = ""
5253
headers = {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "31.0.0",
3+
"files": {
4+
"36618132bd37b6b15f9987b57ad1fbf613f1ad937aec72381232b163ed9c44c4": {
5+
"source": {
6+
"path": "asset.36618132bd37b6b15f9987b57ad1fbf613f1ad937aec72381232b163ed9c44c4.bundle",
7+
"packaging": "zip"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "36618132bd37b6b15f9987b57ad1fbf613f1ad937aec72381232b163ed9c44c4.zip",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
},
17+
"0d889e0d833f8b9b09eff9583a832802952f1f7f181507ea7cec6916c2721470": {
18+
"source": {
19+
"path": "IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json",
20+
"packaging": "file"
21+
},
22+
"destinations": {
23+
"current_account-current_region": {
24+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
25+
"objectKey": "0d889e0d833f8b9b09eff9583a832802952f1f7f181507ea7cec6916c2721470.json",
26+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
27+
}
28+
}
29+
}
30+
},
31+
"dockerImages": {}
32+
}

0 commit comments

Comments
 (0)