Skip to content

Commit

Permalink
feat(synthetics): support runtime nodejs puppeteer 4.0 (#25553)
Browse files Browse the repository at this point in the history
## 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*
  • Loading branch information
WinterYukky authored May 30, 2023
1 parent fec928e commit 1d7a9a8
Show file tree
Hide file tree
Showing 19 changed files with 5,562 additions and 928 deletions.
12 changes: 6 additions & 6 deletions packages/@aws-cdk/aws-synthetics-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const canary = new synthetics.Canary(this, 'MyCanary', {
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
handler: 'index.handler',
}),
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
environmentVariables: {
stage: 'prod',
},
Expand Down Expand Up @@ -120,7 +120,7 @@ const canary = new synthetics.Canary(stack, 'Canary', {
code: synthetics.Code.fromInline('/* Synthetics handler code'),
}),
enableAutoDeleteLambdas: true,
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
});
```

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

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

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

Expand Down Expand Up @@ -205,7 +205,7 @@ new synthetics.Canary(this, 'Vpc Canary', {
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
handler: 'index.handler',
}),
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_9,
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_4_0,
vpc,
});
```
Expand Down
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-synthetics-alpha/lib/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ export class Runtime {
*/
public static readonly SYNTHETICS_NODEJS_PUPPETEER_3_9 = new Runtime('syn-nodejs-puppeteer-3.9', RuntimeFamily.NODEJS);

/**
* `syn-nodejs-puppeteer-4.0` includes the following:
* - Lambda runtime Node.js 16.x
* - Puppeteer-core version 5.5.0
* - Chromium version 92.0.4512
*
* New Features:
* - **Dependency upgrades**: The Node.js dependency is updated to 16.x.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Library_nodejs_puppeteer.html#CloudWatch_Synthetics_runtimeversion-nodejs-puppeteer-4.0
*/
public static readonly SYNTHETICS_NODEJS_PUPPETEER_4_0 = new Runtime('syn-nodejs-puppeteer-4.0', RuntimeFamily.NODEJS);

/**
* `syn-python-selenium-1.0` includes the following:
* - Lambda runtime Python 3.8
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-synthetics-alpha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@aws-cdk/integ-tests-alpha": "0.0.0",
"@types/jest": "^29.5.1",
"jest": "^29.5.0",
"aws-cdk-lib": "0.0.0",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This example comes from the AWS Synthetics service console "API canary" blueprint

import os
import json
import http.client
import urllib.parse
Expand All @@ -23,7 +24,7 @@ def verify_request(method, url, post_data=None, headers={}):
else:
conn = http.client.HTTPConnection(parsed_url.hostname, parsed_url.port)

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

def main():

url = 'https://example.com/'
url = os.environ['URL']
method = 'GET'
postData = ""
headers = {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": "31.0.0",
"files": {
"36618132bd37b6b15f9987b57ad1fbf613f1ad937aec72381232b163ed9c44c4": {
"source": {
"path": "asset.36618132bd37b6b15f9987b57ad1fbf613f1ad937aec72381232b163ed9c44c4.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "36618132bd37b6b15f9987b57ad1fbf613f1ad937aec72381232b163ed9c44c4.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"0d889e0d833f8b9b09eff9583a832802952f1f7f181507ea7cec6916c2721470": {
"source": {
"path": "IntegCanaryTestDefaultTestDeployAssert3AD5A094.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "0d889e0d833f8b9b09eff9583a832802952f1f7f181507ea7cec6916c2721470.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Loading

0 comments on commit 1d7a9a8

Please sign in to comment.