From 18d41000410e428b39cc8b3f646fce89382bd760 Mon Sep 17 00:00:00 2001 From: maz Date: Sat, 15 Jun 2024 20:27:56 +0900 Subject: [PATCH 01/18] feat: add activeTracing, memory and timeout property to Canary class --- .../index.js | 1 + ...k-synthetics-canary-run-config.assets.json | 32 ++ ...synthetics-canary-run-config.template.json | 477 ++++++++++++++++++ .../cdk.out | 1 + ...efaultTestDeployAssertDF592B72.assets.json | 19 + ...aultTestDeployAssertDF592B72.template.json | 36 ++ .../integ.json | 12 + .../manifest.json | 155 ++++++ .../tree.json | 444 ++++++++++++++++ .../test/integ.canary-run-config.ts | 32 ++ packages/aws-cdk-lib/aws-synthetics/README.md | 58 ++- .../aws-cdk-lib/aws-synthetics/lib/canary.ts | 68 ++- .../aws-synthetics/test/canary.test.ts | 132 ++++- 13 files changed, 1463 insertions(+), 4 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/asset.d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d/index.js create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/asset.d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/asset.d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d/index.js new file mode 100644 index 0000000000000..f9cc630970c96 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/asset.d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d/index.js @@ -0,0 +1 @@ +"use strict";var I=Object.create;var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var P=(o,e)=>{for(var t in e)i(o,t,{get:e[t],enumerable:!0})},l=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!A.call(o,s)&&s!==t&&i(o,s,{get:()=>e[s],enumerable:!(n=g(e,s))||n.enumerable});return o};var m=(o,e,t)=>(t=o!=null?I(w(o)):{},l(e||!o||!o.__esModule?i(t,"default",{value:o,enumerable:!0}):t,o)),L=o=>l(i({},"__esModule",{value:!0}),o);var W={};P(W,{autoDeleteHandler:()=>E,handler:()=>_});module.exports=L(W);var c=require("@aws-sdk/client-lambda"),u=require("@aws-sdk/client-synthetics");var y=m(require("https")),R=m(require("url")),a={sendHttpRequest:T,log:F,includeStackTraces:!0,userHandlerIndex:"./index"},p="AWSCDK::CustomResourceProviderFramework::CREATE_FAILED",D="AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID";function C(o){return async(e,t)=>{let n={...e,ResponseURL:"..."};if(a.log(JSON.stringify(n,void 0,2)),e.RequestType==="Delete"&&e.PhysicalResourceId===p){a.log("ignoring DELETE event caused by a failed CREATE event"),await d("SUCCESS",e);return}try{let s=await o(n,t),r=b(e,s);await d("SUCCESS",r)}catch(s){let r={...e,Reason:a.includeStackTraces?s.stack:s.message};r.PhysicalResourceId||(e.RequestType==="Create"?(a.log("CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored"),r.PhysicalResourceId=p):a.log(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify(e)}`)),await d("FAILED",r)}}}function b(o,e={}){let t=e.PhysicalResourceId??o.PhysicalResourceId??o.RequestId;if(o.RequestType==="Delete"&&t!==o.PhysicalResourceId)throw new Error(`DELETE: cannot change the physical resource ID from "${o.PhysicalResourceId}" to "${e.PhysicalResourceId}" during deletion`);return{...o,...e,PhysicalResourceId:t}}async function d(o,e){let t={Status:o,Reason:e.Reason??o,StackId:e.StackId,RequestId:e.RequestId,PhysicalResourceId:e.PhysicalResourceId||D,LogicalResourceId:e.LogicalResourceId,NoEcho:e.NoEcho,Data:e.Data},n=R.parse(e.ResponseURL),s=`${n.protocol}//${n.hostname}/${n.pathname}?***`;a.log("submit response to cloudformation",s,t);let r=JSON.stringify(t),f={hostname:n.hostname,path:n.path,method:"PUT",headers:{"content-type":"","content-length":Buffer.byteLength(r,"utf8")}};await x({attempts:5,sleep:1e3},a.sendHttpRequest)(f,r)}async function T(o,e){return new Promise((t,n)=>{try{let s=y.request(o,r=>{r.resume(),!r.statusCode||r.statusCode>=400?n(new Error(`Unsuccessful HTTP response: ${r.statusCode}`)):t()});s.on("error",n),s.write(e),s.end()}catch(s){n(s)}})}function F(o,...e){console.log(o,...e)}function x(o,e){return async(...t)=>{let n=o.attempts,s=o.sleep;for(;;)try{return await e(...t)}catch(r){if(n--<=0)throw r;await N(Math.floor(Math.random()*s)),s*=2}}}async function N(o){return new Promise(e=>setTimeout(e,o))}var h="aws-cdk:auto-delete-underlying-resources",H=new c.LambdaClient({}),U=new u.SyntheticsClient({}),_=C(E);async function E(o){switch(o.RequestType){case"Create":return{PhyscialResourceId:o.ResourceProperties?.CanaryName};case"Update":return{PhysicalResourceId:(await k(o)).PhysicalResourceId};case"Delete":return q(o.ResourceProperties?.CanaryName)}}async function k(o){return{PhysicalResourceId:o.ResourceProperties?.CanaryName}}async function q(o){if(console.log(`Deleting lambda function associated with ${o}`),!o)throw new Error("No CanaryName was provided.");try{let e=await U.send(new u.GetCanaryCommand({Name:o}));if(e.Canary===void 0||e.Canary.Id===void 0)return;if(e.Canary.EngineArn===void 0)return;if(!O(e.Canary.Tags)){console.log(`Canary does not have '${h}' tag, skipping deletion.`);return}let t=e.Canary.EngineArn.split(":");t.at(-1)?.includes(e.Canary.Id)||t.pop();let n=t.join(":");console.log(`Deleting lambda ${n}`),await H.send(new c.DeleteFunctionCommand({FunctionName:n}))}catch(e){if(e.name!=="ResourceNotFoundException")throw e}}function O(o){return o?Object.keys(o).some(e=>e===h&&o[e]==="true"):!1}0&&(module.exports={autoDeleteHandler,handler}); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json new file mode 100644 index 0000000000000..e1052f472dacc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json @@ -0,0 +1,32 @@ +{ + "version": "36.0.0", + "files": { + "d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d": { + "source": { + "path": "asset.d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "fc29f8df930fff80137fdd7f660261c1880517b5b50f325ab7050b1acc40d27d": { + "source": { + "path": "cdk-synthetics-canary-run-config.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "fc29f8df930fff80137fdd7f660261c1880517b5b50f325ab7050b1acc40d27d.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json new file mode 100644 index 0000000000000..1c4de34ba9ba6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json @@ -0,0 +1,477 @@ +{ + "Resources": { + "CanaryArtifactsBucket4A60D32B": { + "Type": "AWS::S3::Bucket", + "Properties": { + "BucketEncryption": { + "ServerSideEncryptionConfiguration": [ + { + "ServerSideEncryptionByDefault": { + "SSEAlgorithm": "aws:kms" + } + } + ] + } + }, + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "CanaryArtifactsBucketPolicy63096C41": { + "Type": "AWS::S3::BucketPolicy", + "Properties": { + "Bucket": { + "Ref": "CanaryArtifactsBucket4A60D32B" + }, + "PolicyDocument": { + "Statement": [ + { + "Action": "s3:*", + "Condition": { + "Bool": { + "aws:SecureTransport": "false" + } + }, + "Effect": "Deny", + "Principal": { + "AWS": "*" + }, + "Resource": [ + { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + }, + "/*" + ] + ] + } + ] + } + ], + "Version": "2012-10-17" + } + } + }, + "CanaryServiceRoleD132250E": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": "s3:ListAllMyBuckets", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": "s3:GetBucketLocation", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + } + }, + { + "Action": "s3:PutObject", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + }, + "/*" + ] + ] + } + }, + { + "Action": "cloudwatch:PutMetricData", + "Condition": { + "StringEquals": { + "cloudwatch:namespace": "CloudWatchSynthetics" + } + }, + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/lambda/cwsyn-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "canaryPolicy" + } + ] + } + }, + "Canary11957FE2": { + "Type": "AWS::Synthetics::Canary", + "Properties": { + "ArtifactS3Location": { + "Fn::Join": [ + "", + [ + "s3://", + { + "Ref": "CanaryArtifactsBucket4A60D32B" + } + ] + ] + }, + "Code": { + "Handler": "index.handler", + "Script": "\n exports.handler = async () => {\n console.log('hello world');\n };" + }, + "ExecutionRoleArn": { + "Fn::GetAtt": [ + "CanaryServiceRoleD132250E", + "Arn" + ] + }, + "Name": "next", + "RunConfig": { + "ActiveTracing": true, + "MemoryInMB": 1024, + "TimeoutInSeconds": 240 + }, + "RuntimeVersion": "syn-nodejs-puppeteer-7.0", + "Schedule": { + "DurationInSeconds": "0", + "Expression": "rate(5 minutes)" + }, + "StartCanaryAfterCreation": true, + "Tags": [ + { + "Key": "aws-cdk:auto-delete-underlying-resources", + "Value": "true" + } + ] + } + }, + "CanaryAutoDeleteUnderlyingResourcesCustomResource76464216": { + "Type": "Custom::SyntheticsAutoDeleteUnderlyingResources", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderHandler26776D4E", + "Arn" + ] + }, + "CanaryName": { + "Ref": "Canary11957FE2" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderRole2D11A112": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ], + "Policies": [ + { + "PolicyName": "Inline", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "lambda:DeleteFunction" + ], + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":lambda:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":function:cwsyn-*" + ] + ] + } + }, + { + "Effect": "Allow", + "Action": [ + "synthetics:GetCanary" + ], + "Resource": "*" + } + ] + } + } + ] + } + }, + "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderHandler26776D4E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "d57a897c2081bda5ce88819548c8b944dff49e721e1f7f7e9e3dd8323e6ccb0d.zip" + }, + "Timeout": 900, + "MemorySize": 128, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderRole2D11A112", + "Arn" + ] + }, + "Runtime": { + "Fn::FindInMap": [ + "LatestNodeRuntimeMap", + { + "Ref": "AWS::Region" + }, + "value" + ] + }, + "Description": { + "Fn::Join": [ + "", + [ + "Lambda function for auto-deleting underlying resources created by ", + { + "Ref": "Canary11957FE2" + }, + "." + ] + ] + } + }, + "DependsOn": [ + "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderRole2D11A112" + ] + } + }, + "Mappings": { + "LatestNodeRuntimeMap": { + "af-south-1": { + "value": "nodejs20.x" + }, + "ap-east-1": { + "value": "nodejs20.x" + }, + "ap-northeast-1": { + "value": "nodejs20.x" + }, + "ap-northeast-2": { + "value": "nodejs20.x" + }, + "ap-northeast-3": { + "value": "nodejs20.x" + }, + "ap-south-1": { + "value": "nodejs20.x" + }, + "ap-south-2": { + "value": "nodejs20.x" + }, + "ap-southeast-1": { + "value": "nodejs20.x" + }, + "ap-southeast-2": { + "value": "nodejs20.x" + }, + "ap-southeast-3": { + "value": "nodejs20.x" + }, + "ap-southeast-4": { + "value": "nodejs20.x" + }, + "ca-central-1": { + "value": "nodejs20.x" + }, + "cn-north-1": { + "value": "nodejs18.x" + }, + "cn-northwest-1": { + "value": "nodejs18.x" + }, + "eu-central-1": { + "value": "nodejs20.x" + }, + "eu-central-2": { + "value": "nodejs20.x" + }, + "eu-north-1": { + "value": "nodejs20.x" + }, + "eu-south-1": { + "value": "nodejs20.x" + }, + "eu-south-2": { + "value": "nodejs20.x" + }, + "eu-west-1": { + "value": "nodejs20.x" + }, + "eu-west-2": { + "value": "nodejs20.x" + }, + "eu-west-3": { + "value": "nodejs20.x" + }, + "il-central-1": { + "value": "nodejs20.x" + }, + "me-central-1": { + "value": "nodejs20.x" + }, + "me-south-1": { + "value": "nodejs20.x" + }, + "sa-east-1": { + "value": "nodejs20.x" + }, + "us-east-1": { + "value": "nodejs20.x" + }, + "us-east-2": { + "value": "nodejs20.x" + }, + "us-gov-east-1": { + "value": "nodejs18.x" + }, + "us-gov-west-1": { + "value": "nodejs18.x" + }, + "us-iso-east-1": { + "value": "nodejs18.x" + }, + "us-iso-west-1": { + "value": "nodejs18.x" + }, + "us-isob-east-1": { + "value": "nodejs18.x" + }, + "us-west-1": { + "value": "nodejs20.x" + }, + "us-west-2": { + "value": "nodejs20.x" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk.out new file mode 100644 index 0000000000000..1f0068d32659a --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets.json new file mode 100644 index 0000000000000..9f337c19f4367 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/integ.json new file mode 100644 index 0000000000000..3c68065f3464b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "cdk-integ-synthetics-canary-run-config/DefaultTest": { + "stacks": [ + "cdk-synthetics-canary-run-config" + ], + "assertionStack": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert", + "assertionStackName": "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json new file mode 100644 index 0000000000000..9d3e24f4006cf --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json @@ -0,0 +1,155 @@ +{ + "version": "36.0.0", + "artifacts": { + "cdk-synthetics-canary-run-config.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "cdk-synthetics-canary-run-config.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "cdk-synthetics-canary-run-config": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "cdk-synthetics-canary-run-config.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/fc29f8df930fff80137fdd7f660261c1880517b5b50f325ab7050b1acc40d27d.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "cdk-synthetics-canary-run-config.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "cdk-synthetics-canary-run-config.assets" + ], + "metadata": { + "/cdk-synthetics-canary-run-config/Canary/ArtifactsBucket/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "CanaryArtifactsBucket4A60D32B" + } + ], + "/cdk-synthetics-canary-run-config/Canary/ArtifactsBucket/Policy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "CanaryArtifactsBucketPolicy63096C41" + } + ], + "/cdk-synthetics-canary-run-config/Canary/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "CanaryServiceRoleD132250E" + } + ], + "/cdk-synthetics-canary-run-config/Canary/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Canary11957FE2" + } + ], + "/cdk-synthetics-canary-run-config/Canary/AutoDeleteUnderlyingResourcesCustomResource/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "CanaryAutoDeleteUnderlyingResourcesCustomResource76464216" + } + ], + "/cdk-synthetics-canary-run-config/LatestNodeRuntimeMap": [ + { + "type": "aws:cdk:logicalId", + "data": "LatestNodeRuntimeMap" + } + ], + "/cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderRole2D11A112" + } + ], + "/cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomSyntheticsAutoDeleteUnderlyingResourcesCustomResourceProviderHandler26776D4E" + } + ], + "/cdk-synthetics-canary-run-config/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/cdk-synthetics-canary-run-config/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "cdk-synthetics-canary-run-config" + }, + "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "cdkintegsyntheticscanaryrunconfigDefaultTestDeployAssertDF592B72.assets" + ], + "metadata": { + "/cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json new file mode 100644 index 0000000000000..da08bc56463c9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json @@ -0,0 +1,444 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "cdk-synthetics-canary-run-config": { + "id": "cdk-synthetics-canary-run-config", + "path": "cdk-synthetics-canary-run-config", + "children": { + "Canary": { + "id": "Canary", + "path": "cdk-synthetics-canary-run-config/Canary", + "children": { + "ArtifactsBucket": { + "id": "ArtifactsBucket", + "path": "cdk-synthetics-canary-run-config/Canary/ArtifactsBucket", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-synthetics-canary-run-config/Canary/ArtifactsBucket/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::S3::Bucket", + "aws:cdk:cloudformation:props": { + "bucketEncryption": { + "serverSideEncryptionConfiguration": [ + { + "serverSideEncryptionByDefault": { + "sseAlgorithm": "aws:kms" + } + } + ] + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Policy": { + "id": "Policy", + "path": "cdk-synthetics-canary-run-config/Canary/ArtifactsBucket/Policy", + "children": { + "Resource": { + "id": "Resource", + "path": "cdk-synthetics-canary-run-config/Canary/ArtifactsBucket/Policy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::S3::BucketPolicy", + "aws:cdk:cloudformation:props": { + "bucket": { + "Ref": "CanaryArtifactsBucket4A60D32B" + }, + "policyDocument": { + "Statement": [ + { + "Action": "s3:*", + "Condition": { + "Bool": { + "aws:SecureTransport": "false" + } + }, + "Effect": "Deny", + "Principal": { + "AWS": "*" + }, + "Resource": [ + { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + }, + { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + }, + "/*" + ] + ] + } + ] + } + ], + "Version": "2012-10-17" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "ServiceRole": { + "id": "ServiceRole", + "path": "cdk-synthetics-canary-run-config/Canary/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "cdk-synthetics-canary-run-config/Canary/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-synthetics-canary-run-config/Canary/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "policies": [ + { + "policyName": "canaryPolicy", + "policyDocument": { + "Statement": [ + { + "Action": "s3:ListAllMyBuckets", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": "s3:GetBucketLocation", + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + } + }, + { + "Action": "s3:PutObject", + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + { + "Fn::GetAtt": [ + "CanaryArtifactsBucket4A60D32B", + "Arn" + ] + }, + "/*" + ] + ] + } + }, + { + "Action": "cloudwatch:PutMetricData", + "Condition": { + "StringEquals": { + "cloudwatch:namespace": "CloudWatchSynthetics" + } + }, + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":logs:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":log-group:/aws/lambda/cwsyn-*" + ] + ] + } + } + ], + "Version": "2012-10-17" + } + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Resource": { + "id": "Resource", + "path": "cdk-synthetics-canary-run-config/Canary/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Synthetics::Canary", + "aws:cdk:cloudformation:props": { + "artifactS3Location": { + "Fn::Join": [ + "", + [ + "s3://", + { + "Ref": "CanaryArtifactsBucket4A60D32B" + } + ] + ] + }, + "code": { + "handler": "index.handler", + "script": "\n exports.handler = async () => {\n console.log('hello world');\n };" + }, + "executionRoleArn": { + "Fn::GetAtt": [ + "CanaryServiceRoleD132250E", + "Arn" + ] + }, + "name": "next", + "runConfig": { + "activeTracing": true, + "memoryInMb": 1024, + "timeoutInSeconds": 240 + }, + "runtimeVersion": "syn-nodejs-puppeteer-7.0", + "schedule": { + "durationInSeconds": "0", + "expression": "rate(5 minutes)" + }, + "startCanaryAfterCreation": true, + "tags": [ + { + "key": "aws-cdk:auto-delete-underlying-resources", + "value": "true" + } + ] + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "AutoDeleteUnderlyingResourcesCustomResource": { + "id": "AutoDeleteUnderlyingResourcesCustomResource", + "path": "cdk-synthetics-canary-run-config/Canary/AutoDeleteUnderlyingResourcesCustomResource", + "children": { + "Default": { + "id": "Default", + "path": "cdk-synthetics-canary-run-config/Canary/AutoDeleteUnderlyingResourcesCustomResource/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "LatestNodeRuntimeMap": { + "id": "LatestNodeRuntimeMap", + "path": "cdk-synthetics-canary-run-config/LatestNodeRuntimeMap", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider": { + "id": "Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider", + "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider", + "children": { + "Staging": { + "id": "Staging", + "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Staging", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Role": { + "id": "Role", + "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Role", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "Handler": { + "id": "Handler", + "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Handler", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-synthetics-canary-run-config/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-synthetics-canary-run-config/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "cdk-integ-synthetics-canary-run-config": { + "id": "cdk-integ-synthetics-canary-run-config", + "path": "cdk-integ-synthetics-canary-run-config", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "cdk-integ-synthetics-canary-run-config/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "cdk-integ-synthetics-canary-run-config/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts new file mode 100644 index 0000000000000..74e57cad758a7 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts @@ -0,0 +1,32 @@ +import { App, Duration, Size, Stack, StackProps } from 'aws-cdk-lib/core'; +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import { Construct } from 'constructs'; +import * as synthetics from 'aws-cdk-lib/aws-synthetics'; + +class TestStack extends Stack { + constructor(scope: Construct, id: string, props?: StackProps) { + super(scope, id, props); + + new synthetics.Canary(this, 'Canary', { + canaryName: 'next', + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline(` + exports.handler = async () => { + console.log(\'hello world\'); + };`), + }), + cleanup: synthetics.Cleanup.LAMBDA, + activeTracing: true, + memory: Size.mebibytes(1024), + timeout: Duration.minutes(4), + }); + } +} + +const app = new App(); + +new IntegTest(app, 'cdk-integ-synthetics-canary-run-config', { + testCases: [new TestStack(app, 'cdk-synthetics-canary-run-config')], +}); diff --git a/packages/aws-cdk-lib/aws-synthetics/README.md b/packages/aws-cdk-lib/aws-synthetics/README.md index c4ec669708416..46dc18c7753f0 100644 --- a/packages/aws-cdk-lib/aws-synthetics/README.md +++ b/packages/aws-cdk-lib/aws-synthetics/README.md @@ -87,6 +87,62 @@ const schedule = synthetics.Schedule.cron({ If you want the canary to run just once upon deployment, you can use `Schedule.once()`. +### Active Tracing + +You can choose to enable active AWS X-Ray tracing on canaries that use the syn-nodejs-2.0 or later runtime by setting `activeTracing` to `true`. + +With tracing enabled, traces are sent for all calls made by the canary that use the browser, the AWS SDK, or HTTP or HTTPS modules. + +For more information, see [Canaries and X-Ray tracing](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html). + +```ts +const canary = new synthetics.Canary(this, 'MyCanary', { + schedule: synthetics.Schedule.rate(Duration.minutes(5)), + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2, + activeTracing: true, // active tracing enabled +}); +``` + +### Memory + +You can set the maximum amount of memory that the canary can use while running by setting `memory`. + +```ts +import * as cdk from "aws-cdk-lib"; + +const canary = new synthetics.Canary(this, 'MyCanary', { + schedule: synthetics.Schedule.rate(Duration.minutes(5)), + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2, + memory: cdk.Size.mebibytes(1024), // 1024 MiB +}); +``` + +### Timeout + +You can set how long the canary is allowed to run before it must stop by setting `timeout`. + +```ts +import * as cdk from "aws-cdk-lib"; + +const canary = new synthetics.Canary(this, 'MyCanary', { + schedule: synthetics.Schedule.rate(Duration.minutes(5)), + test: synthetics.Test.custom({ + code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')), + handler: 'index.handler', + }), + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2, + timeout: cdk.Duration.seconds(60), // 60 seconds +}); +``` + ### Deleting underlying resources on canary deletion When you delete a lambda, the following underlying resources are isolated in your AWS account: @@ -114,7 +170,7 @@ const canary = new synthetics.Canary(this, 'Canary', { }); ``` -> Note: To properly clean up your canary on deletion, you still have to manually delete other resources +> Note: To properly clean up your canary on deletion, you still have to manually delete other resources > like S3 buckets and CloudWatch logs. ### Configuring the Canary Script diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 2c49036174bf2..192d0adb8cd9b 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -179,6 +179,20 @@ export interface CanaryProps { */ readonly test: Test; + /** + * Specifies whether this canary is to use active AWS X-Ray tracing when it runs. + * Active tracing enables this canary run to be displayed in the ServiceLens and X-Ray service maps even if the + * canary does not hit an endpoint that has X-Ray tracing enabled. Using X-Ray tracing incurs charges. + * + * You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime. + * + * @default false + * + * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html + */ + + readonly activeTracing?: boolean; + /** * Key-value pairs that the Synthetics caches and makes available for your canary scripts. Use environment variables * to apply configuration changes, such as test and production environment configurations, without changing your @@ -188,6 +202,22 @@ export interface CanaryProps { */ readonly environmentVariables?: { [key: string]: string }; + /** + * The maximum amount of memory that the canary can use while running. + * This value must be a multiple of 64 Mib. + * + * @default Size.mebibytes(5) + */ + readonly memory?: cdk.Size; + + /** + * How long the canary is allowed to run before it must stop. + * You can't set this time to be longer than the frequency of the runs of this canary. + * + * @default - the frequency of the canary is used as this value, up to a maximum of 900 seconds. + */ + readonly timeout?: cdk.Duration; + /** * The VPC where this canary is run. * @@ -420,7 +450,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { actions: ['s3:GetBucketLocation'], }), new iam.PolicyStatement({ - resources: [this.artifactsBucket.arnForObjects(`${prefix ? prefix+'/*' : '*'}`)], + resources: [this.artifactsBucket.arnForObjects(`${prefix ? prefix + '/*' : '*'}`)], actions: ['s3:PutObject'], }), new iam.PolicyStatement({ @@ -513,11 +543,45 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { } private createRunConfig(props: CanaryProps): CfnCanary.RunConfigProperty | undefined { - if (!props.environmentVariables) { + if (props.activeTracing === undefined && + !props.environmentVariables && + !props.memory && + !props.timeout) { return undefined; } + const activeTracingNotSupportedRuntime = [ + Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, + Runtime.SYNTHETICS_PYTHON_SELENIUM_3_0, + ]; + + if (props.activeTracing && activeTracingNotSupportedRuntime.includes(props.runtime)) { + throw new Error('You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime.'); + } + + let memoryInMb = undefined; + if (!cdk.Token.isUnresolved(props.memory) && props.memory) { + memoryInMb = props.memory.toMebibytes(); + if (memoryInMb % 64 !== 0) { + throw new Error(`\`memory\` must be a multiple of 64 MiB, got ${memoryInMb} MiB.`); + } + if (memoryInMb < 960 || memoryInMb > 3008) { + throw new Error(`\`memory\` must be between 960 MiB and 3008 MiB, got ${memoryInMb} MiB.`); + } + } + + let timeoutInSeconds = undefined; + if (!cdk.Token.isUnresolved(props.timeout) && props.timeout) { + timeoutInSeconds = props.timeout.toSeconds(); + if (timeoutInSeconds < 3 || timeoutInSeconds > 840) { + throw new Error(`\`timeout\` must be between 3 seconds and 840 seconds, got ${timeoutInSeconds} seconds.`); + } + } + return { + activeTracing: props.activeTracing, environmentVariables: props.environmentVariables, + memoryInMb, + timeoutInSeconds, }; } diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 5481002b9d579..757b02f2d7795 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -3,7 +3,7 @@ import { Match, Template } from '../../assertions'; import * as ec2 from '../../aws-ec2'; import * as iam from '../../aws-iam'; import * as s3 from '../../aws-s3'; -import { Duration, Lazy, Stack } from '../../core'; +import { Duration, Lazy, Size, Stack } from '../../core'; import * as synthetics from '../lib'; test('Basic canary properties work', () => { @@ -237,6 +237,44 @@ test('Python runtime can be specified', () => { }); }); +test.each([true, false])('activeTracing can be set to %s', (activeTracing: boolean) => { + // GIVEN + const stack = new Stack(); + + // WHEN + new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + activeTracing, + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { + RunConfig: { + ActiveTracing: activeTracing, + }, + }); +}); + +test('throws when activeTracing is enabled with an unsupported runtime', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + expect(() => new synthetics.Canary(stack, 'Canary', { + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('# Synthetics handler code'), + }), + runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, + activeTracing: true, + })) + .toThrow('You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime.'); +}); + test('environment variables can be specified', () => { // GIVEN const stack = new Stack(); @@ -282,6 +320,98 @@ test('environment variables are skipped if not provided', () => { }); }); +test('memory can be set', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + memory: Size.mebibytes(1024), + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { + RunConfig: { + MemoryInMB: 1024, + }, + }); +}); + +test('throws when memory is not a multiple of 64 MiB', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + expect(() => new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + memory: Size.mebibytes(5), + })) + .toThrow('\`memory\` must be a multiple of 64 MiB, got 5 MiB.'); +}); + +test.each([64, 6400])('throws when memory is out of range, %d MiB', (memoryInMb: number) => { + // GIVEN + const stack = new Stack(); + + // WHEN + expect(() => new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + memory: Size.mebibytes(memoryInMb), + })) + .toThrow(`\`memory\` must be between 960 MiB and 3008 MiB, got ${memoryInMb} MiB.`); +}); + +test('timeout can be set', () => { + // GIVEN + const stack = new Stack(); + + // WHEN + new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + timeout: Duration.seconds(60), + }); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Synthetics::Canary', { + RunConfig: { + TimeoutInSeconds: 60, + }, + }); +}); + +test.each([2, 900])('throws when timeout is out of range, %d seconds', (seconds: number) => { + // GIVEN + const stack = new Stack(); + + // WHEN + expect(() => new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + timeout: Duration.seconds(seconds), + })) + .toThrow(`\`timeout\` must be between 3 seconds and 840 seconds, got ${seconds} seconds.`); +}); + test('Runtime can be customized', () => { // GIVEN const stack = new Stack(); From f6f7b519229658caf693095f233f6020751dbe2e Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:45:41 +0900 Subject: [PATCH 02/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 192d0adb8cd9b..e5421c06d2fdd 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -184,7 +184,7 @@ export interface CanaryProps { * Active tracing enables this canary run to be displayed in the ServiceLens and X-Ray service maps even if the * canary does not hit an endpoint that has X-Ray tracing enabled. Using X-Ray tracing incurs charges. * - * You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime. + * You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime. * * @default false * From 011e4f97125433a25a763e215fbc98c283bce43a Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:45:53 +0900 Subject: [PATCH 03/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index e5421c06d2fdd..868fc5d646300 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -190,7 +190,6 @@ export interface CanaryProps { * * @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html */ - readonly activeTracing?: boolean; /** From ba7dc65e11c54bdf12e2bd22f13696175b65e4b7 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:46:08 +0900 Subject: [PATCH 04/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 868fc5d646300..37faaf7232a26 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -204,6 +204,7 @@ export interface CanaryProps { /** * The maximum amount of memory that the canary can use while running. * This value must be a multiple of 64 Mib. + * The range is 960 MiB to 3008 MiB. * * @default Size.mebibytes(5) */ From 819536a30d1c095df5d39c6094b71eb2e54c48f4 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:46:17 +0900 Subject: [PATCH 05/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 37faaf7232a26..89640bca7d0da 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -214,6 +214,9 @@ export interface CanaryProps { * How long the canary is allowed to run before it must stop. * You can't set this time to be longer than the frequency of the runs of this canary. * + * The minimum allowed value is 3 seconds. + * The maximum allowed value is 840 seconds (14 minutes). + * * @default - the frequency of the canary is used as this value, up to a maximum of 900 seconds. */ readonly timeout?: cdk.Duration; From 104d50cb4bd157452ef10dd86e265d5dcd869248 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:46:26 +0900 Subject: [PATCH 06/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 89640bca7d0da..d1322cd57e858 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -558,7 +558,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { ]; if (props.activeTracing && activeTracingNotSupportedRuntime.includes(props.runtime)) { - throw new Error('You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime.'); + throw new Error('You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime.'); } let memoryInMb = undefined; From 2f0668af39318b7258711f7f01c694d04f626808 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:46:38 +0900 Subject: [PATCH 07/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index d1322cd57e858..6ac3a8b3ff5b4 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -561,7 +561,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { throw new Error('You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime.'); } - let memoryInMb = undefined; + let memoryInMb: number | undefined; if (!cdk.Token.isUnresolved(props.memory) && props.memory) { memoryInMb = props.memory.toMebibytes(); if (memoryInMb % 64 !== 0) { From 1aa8741dbe89e47f83331326bdaa5e5377c499b5 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:46:49 +0900 Subject: [PATCH 08/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 6ac3a8b3ff5b4..7c3721185bc9f 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -562,7 +562,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { } let memoryInMb: number | undefined; - if (!cdk.Token.isUnresolved(props.memory) && props.memory) { + if (!cdk.Token.isUnresolved(props.memory) && props.memory !== undefined) { memoryInMb = props.memory.toMebibytes(); if (memoryInMb % 64 !== 0) { throw new Error(`\`memory\` must be a multiple of 64 MiB, got ${memoryInMb} MiB.`); From 7714123049719a50dbd74d4e28505b1086152175 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:47:03 +0900 Subject: [PATCH 09/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 7c3721185bc9f..9c87699e7577a 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -572,7 +572,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { } } - let timeoutInSeconds = undefined; + let timeoutInSeconds: number | undefined; if (!cdk.Token.isUnresolved(props.timeout) && props.timeout) { timeoutInSeconds = props.timeout.toSeconds(); if (timeoutInSeconds < 3 || timeoutInSeconds > 840) { From ff54d2656deeda513aeae9f8280c25e7e7afe9fe Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:47:14 +0900 Subject: [PATCH 10/18] Update packages/aws-cdk-lib/aws-synthetics/lib/canary.ts Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 9c87699e7577a..a3d3b38d78cad 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -573,7 +573,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { } let timeoutInSeconds: number | undefined; - if (!cdk.Token.isUnresolved(props.timeout) && props.timeout) { + if (!cdk.Token.isUnresolved(props.timeout) && props.timeout !== undefined) { timeoutInSeconds = props.timeout.toSeconds(); if (timeoutInSeconds < 3 || timeoutInSeconds > 840) { throw new Error(`\`timeout\` must be between 3 seconds and 840 seconds, got ${timeoutInSeconds} seconds.`); From d858093317dc8661642e46f2ba241bcc97a6e983 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:48:14 +0900 Subject: [PATCH 11/18] Update packages/aws-cdk-lib/aws-synthetics/README.md Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/README.md b/packages/aws-cdk-lib/aws-synthetics/README.md index 46dc18c7753f0..9362cc8f8f426 100644 --- a/packages/aws-cdk-lib/aws-synthetics/README.md +++ b/packages/aws-cdk-lib/aws-synthetics/README.md @@ -89,7 +89,7 @@ If you want the canary to run just once upon deployment, you can use `Schedule.o ### Active Tracing -You can choose to enable active AWS X-Ray tracing on canaries that use the syn-nodejs-2.0 or later runtime by setting `activeTracing` to `true`. +You can choose to enable active AWS X-Ray tracing on canaries that use the `syn-nodejs-2.0` or later runtime by setting `activeTracing` to `true`. With tracing enabled, traces are sent for all calls made by the canary that use the browser, the AWS SDK, or HTTP or HTTPS modules. From 65c298b74deccea0373982783935eb208942bc52 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:48:27 +0900 Subject: [PATCH 12/18] Update packages/aws-cdk-lib/aws-synthetics/README.md Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/README.md b/packages/aws-cdk-lib/aws-synthetics/README.md index 9362cc8f8f426..a09ae8ed1b841 100644 --- a/packages/aws-cdk-lib/aws-synthetics/README.md +++ b/packages/aws-cdk-lib/aws-synthetics/README.md @@ -109,7 +109,7 @@ const canary = new synthetics.Canary(this, 'MyCanary', { ### Memory -You can set the maximum amount of memory that the canary can use while running by setting `memory`. +You can set the maximum amount of memory the canary can use while running with the `memory` property. ```ts import * as cdk from "aws-cdk-lib"; From 25f0197c02a5a4cd7bc2057aaa7872b72455c200 Mon Sep 17 00:00:00 2001 From: mazyu36 Date: Mon, 17 Jun 2024 16:48:37 +0900 Subject: [PATCH 13/18] Update packages/aws-cdk-lib/aws-synthetics/README.md Co-authored-by: Luca Pizzini --- packages/aws-cdk-lib/aws-synthetics/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/README.md b/packages/aws-cdk-lib/aws-synthetics/README.md index a09ae8ed1b841..9fc7620f4faae 100644 --- a/packages/aws-cdk-lib/aws-synthetics/README.md +++ b/packages/aws-cdk-lib/aws-synthetics/README.md @@ -127,7 +127,7 @@ const canary = new synthetics.Canary(this, 'MyCanary', { ### Timeout -You can set how long the canary is allowed to run before it must stop by setting `timeout`. +You can set how long the canary is allowed to run before it must stop with the `timeout` property. ```ts import * as cdk from "aws-cdk-lib"; From d156e92ba3ca7ca780d76f4cf6fb8fbcc950c199 Mon Sep 17 00:00:00 2001 From: maz Date: Mon, 17 Jun 2024 17:36:38 +0900 Subject: [PATCH 14/18] fix: incorporate review comments --- ...k-synthetics-canary-run-config.assets.json | 4 +- ...synthetics-canary-run-config.template.json | 2 +- .../manifest.json | 2 +- .../tree.json | 94 +++++++++---------- .../test/integ.canary-run-config.ts | 2 +- .../aws-cdk-lib/aws-synthetics/lib/canary.ts | 11 +-- .../aws-synthetics/test/canary.test.ts | 2 +- 7 files changed, 57 insertions(+), 60 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json index e1052f472dacc..512aa7f35402b 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json @@ -14,7 +14,7 @@ } } }, - "fc29f8df930fff80137fdd7f660261c1880517b5b50f325ab7050b1acc40d27d": { + "df73ec35bdcbc602eea13aa008c3dc6df625970b6caf4ee5d70b93f57443903b": { "source": { "path": "cdk-synthetics-canary-run-config.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "fc29f8df930fff80137fdd7f660261c1880517b5b50f325ab7050b1acc40d27d.json", + "objectKey": "df73ec35bdcbc602eea13aa008c3dc6df625970b6caf4ee5d70b93f57443903b.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json index 1c4de34ba9ba6..63ac4eddfe0c7 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json @@ -188,7 +188,7 @@ "Name": "next", "RunConfig": { "ActiveTracing": true, - "MemoryInMB": 1024, + "MemoryInMB": 2048, "TimeoutInSeconds": 240 }, "RuntimeVersion": "syn-nodejs-puppeteer-7.0", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json index 9d3e24f4006cf..dfd0f1761a95f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/fc29f8df930fff80137fdd7f660261c1880517b5b50f325ab7050b1acc40d27d.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/df73ec35bdcbc602eea13aa008c3dc6df625970b6caf4ee5d70b93f57443903b.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json index da08bc56463c9..7e2ce6ee898b1 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/tree.json @@ -34,8 +34,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_s3.CfnBucket", + "version": "0.0.0" } }, "Policy": { @@ -93,20 +93,20 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_s3.CfnBucketPolicy", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_s3.BucketPolicy", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_s3.Bucket", + "version": "0.0.0" } }, "ServiceRole": { @@ -117,8 +117,8 @@ "id": "ImportServiceRole", "path": "cdk-synthetics-canary-run-config/Canary/ServiceRole/ImportServiceRole", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" } }, "Resource": { @@ -223,14 +223,14 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" } }, "Resource": { @@ -263,7 +263,7 @@ "name": "next", "runConfig": { "activeTracing": true, - "memoryInMb": 1024, + "memoryInMb": 2048, "timeoutInSeconds": 240 }, "runtimeVersion": "syn-nodejs-puppeteer-7.0", @@ -281,8 +281,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_synthetics.CfnCanary", + "version": "0.0.0" } }, "AutoDeleteUnderlyingResourcesCustomResource": { @@ -293,28 +293,28 @@ "id": "Default", "path": "cdk-synthetics-canary-run-config/Canary/AutoDeleteUnderlyingResourcesCustomResource/Default", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.aws_synthetics.Canary", + "version": "0.0.0" } }, "LatestNodeRuntimeMap": { "id": "LatestNodeRuntimeMap", "path": "cdk-synthetics-canary-run-config/LatestNodeRuntimeMap", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnMapping", + "version": "0.0.0" } }, "Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider": { @@ -325,52 +325,52 @@ "id": "Staging", "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Staging", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" } }, "Role": { "id": "Role", "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Role", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" } }, "Handler": { "id": "Handler", "path": "cdk-synthetics-canary-run-config/Custom::SyntheticsAutoDeleteUnderlyingResourcesCustomResourceProvider/Handler", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CustomResourceProviderBase", + "version": "0.0.0" } }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "cdk-synthetics-canary-run-config/BootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "cdk-synthetics-canary-run-config/CheckBootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" } }, "cdk-integ-synthetics-canary-run-config": { @@ -397,22 +397,22 @@ "id": "BootstrapVersion", "path": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert/BootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" } }, "CheckBootstrapVersion": { "id": "CheckBootstrapVersion", "path": "cdk-integ-synthetics-canary-run-config/DefaultTest/DeployAssert/CheckBootstrapVersion", "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" } } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" } } }, @@ -437,8 +437,8 @@ } }, "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0" + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" } } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts index 74e57cad758a7..d437f9600091a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.ts @@ -19,7 +19,7 @@ class TestStack extends Stack { }), cleanup: synthetics.Cleanup.LAMBDA, activeTracing: true, - memory: Size.mebibytes(1024), + memory: Size.mebibytes(2048), timeout: Duration.minutes(4), }); } diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index a3d3b38d78cad..b48cdb82649e6 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -1,7 +1,7 @@ import * as crypto from 'crypto'; import { Construct } from 'constructs'; import { Code } from './code'; -import { Runtime } from './runtime'; +import { Runtime, RuntimeFamily } from './runtime'; import { Schedule } from './schedule'; import { CloudWatchSyntheticsMetrics } from './synthetics-canned-metrics.generated'; import { CfnCanary } from './synthetics.generated'; @@ -206,7 +206,7 @@ export interface CanaryProps { * This value must be a multiple of 64 Mib. * The range is 960 MiB to 3008 MiB. * - * @default Size.mebibytes(5) + * @default Size.mebibytes(1024) */ readonly memory?: cdk.Size; @@ -552,12 +552,9 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { !props.timeout) { return undefined; } - const activeTracingNotSupportedRuntime = [ - Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, - Runtime.SYNTHETICS_PYTHON_SELENIUM_3_0, - ]; - if (props.activeTracing && activeTracingNotSupportedRuntime.includes(props.runtime)) { + // Only check runtime family is nodejs because versions prior to syn-nodejs-2.0 are deprecated and can no longer be configured. + if (props.activeTracing && !cdk.Token.isUnresolved(props.runtime.family) && props.runtime.family !== RuntimeFamily.NODEJS) { throw new Error('You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime.'); } diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 757b02f2d7795..5d70ab0c3a8d4 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -272,7 +272,7 @@ test('throws when activeTracing is enabled with an unsupported runtime', () => { runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, activeTracing: true, })) - .toThrow('You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime.'); + .toThrow('You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime.'); }); test('environment variables can be specified', () => { From 9d08774f56a3618da98722ac006e768ec11e828d Mon Sep 17 00:00:00 2001 From: maz Date: Tue, 18 Jun 2024 10:11:19 +0900 Subject: [PATCH 15/18] fix: add validation --- .../aws-cdk-lib/aws-synthetics/lib/canary.ts | 5 +++++ .../aws-synthetics/test/canary.test.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index b48cdb82649e6..deadfd1cdcd4d 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -571,6 +571,11 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { let timeoutInSeconds: number | undefined; if (!cdk.Token.isUnresolved(props.timeout) && props.timeout !== undefined) { + const timeoutInMillis = props.timeout?.toMilliseconds(); + if (timeoutInMillis % 1000 !== 0) { + throw new Error(`\`timeout\` must be set as an integer representing seconds, got ${timeoutInMillis} milliseconds.`); + } + timeoutInSeconds = props.timeout.toSeconds(); if (timeoutInSeconds < 3 || timeoutInSeconds > 840) { throw new Error(`\`timeout\` must be between 3 seconds and 840 seconds, got ${timeoutInSeconds} seconds.`); diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 5d70ab0c3a8d4..7c29bcf5e6026 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -396,6 +396,22 @@ test('timeout can be set', () => { }); }); +test.each([100, 3100])('throws when timeout is not set as an integer representing seconds , %d milliseconds', (milliseconds: number) => { + // GIVEN + const stack = new Stack(); + + // WHEN + expect(() => new synthetics.Canary(stack, 'Canary', { + runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0, + test: synthetics.Test.custom({ + handler: 'index.handler', + code: synthetics.Code.fromInline('/* Synthetics handler code */'), + }), + timeout: Duration.millis(milliseconds), + })) + .toThrow(`\`timeout\` must be set as an integer representing seconds, got ${milliseconds} milliseconds.`); +}); + test.each([2, 900])('throws when timeout is out of range, %d seconds', (seconds: number) => { // GIVEN const stack = new Stack(); From c32f70cc2eb2d8fc137cc4ec72bc0dd97c1dfb26 Mon Sep 17 00:00:00 2001 From: maz Date: Wed, 19 Jun 2024 01:07:22 +0900 Subject: [PATCH 16/18] chore: minor update --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index deadfd1cdcd4d..68ce2ab642f01 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -571,7 +571,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { let timeoutInSeconds: number | undefined; if (!cdk.Token.isUnresolved(props.timeout) && props.timeout !== undefined) { - const timeoutInMillis = props.timeout?.toMilliseconds(); + const timeoutInMillis = props.timeout.toMilliseconds(); if (timeoutInMillis % 1000 !== 0) { throw new Error(`\`timeout\` must be set as an integer representing seconds, got ${timeoutInMillis} milliseconds.`); } From 0cba11c05d715288ec560c35600c4eaf9ac3c747 Mon Sep 17 00:00:00 2001 From: maz Date: Wed, 24 Jul 2024 21:45:53 +0900 Subject: [PATCH 17/18] update integ test --- .../cdk-synthetics-canary-run-config.assets.json | 4 ++-- ...cdk-synthetics-canary-run-config.template.json | 15 +++++++++++++++ .../manifest.json | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json index 512aa7f35402b..b20822080fb64 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.assets.json @@ -14,7 +14,7 @@ } } }, - "df73ec35bdcbc602eea13aa008c3dc6df625970b6caf4ee5d70b93f57443903b": { + "2419aea0c8a75517961151282103f80d51914702e8458f09e1b5afc1762710de": { "source": { "path": "cdk-synthetics-canary-run-config.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "df73ec35bdcbc602eea13aa008c3dc6df625970b6caf4ee5d70b93f57443903b.json", + "objectKey": "2419aea0c8a75517961151282103f80d51914702e8458f09e1b5afc1762710de.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json index 63ac4eddfe0c7..12afbb2943e95 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/cdk-synthetics-canary-run-config.template.json @@ -366,9 +366,18 @@ "ap-southeast-4": { "value": "nodejs20.x" }, + "ap-southeast-5": { + "value": "nodejs20.x" + }, + "ap-southeast-7": { + "value": "nodejs20.x" + }, "ca-central-1": { "value": "nodejs20.x" }, + "ca-west-1": { + "value": "nodejs20.x" + }, "cn-north-1": { "value": "nodejs18.x" }, @@ -381,6 +390,9 @@ "eu-central-2": { "value": "nodejs20.x" }, + "eu-isoe-west-1": { + "value": "nodejs18.x" + }, "eu-north-1": { "value": "nodejs20.x" }, @@ -408,6 +420,9 @@ "me-south-1": { "value": "nodejs20.x" }, + "mx-central-1": { + "value": "nodejs20.x" + }, "sa-east-1": { "value": "nodejs20.x" }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json index dfd0f1761a95f..6c984c2b05d54 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-synthetics/test/integ.canary-run-config.js.snapshot/manifest.json @@ -18,7 +18,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/df73ec35bdcbc602eea13aa008c3dc6df625970b6caf4ee5d70b93f57443903b.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/2419aea0c8a75517961151282103f80d51914702e8458f09e1b5afc1762710de.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ From eee4cb06fef8b5dce28ad109a4864f804dd59cf9 Mon Sep 17 00:00:00 2001 From: maz Date: Wed, 31 Jul 2024 08:12:10 +0900 Subject: [PATCH 18/18] update error message --- packages/aws-cdk-lib/aws-synthetics/lib/canary.ts | 2 +- packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index 68ce2ab642f01..530050720f5dc 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -555,7 +555,7 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { // Only check runtime family is nodejs because versions prior to syn-nodejs-2.0 are deprecated and can no longer be configured. if (props.activeTracing && !cdk.Token.isUnresolved(props.runtime.family) && props.runtime.family !== RuntimeFamily.NODEJS) { - throw new Error('You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime.'); + throw new Error('You can only enable active tracing for canaries that use canary runtime version `syn-nodejs-2.0` or later.'); } let memoryInMb: number | undefined; diff --git a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts index 09209df9b14f1..f418ce6728b40 100644 --- a/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts +++ b/packages/aws-cdk-lib/aws-synthetics/test/canary.test.ts @@ -272,7 +272,7 @@ test('throws when activeTracing is enabled with an unsupported runtime', () => { runtime: synthetics.Runtime.SYNTHETICS_PYTHON_SELENIUM_2_1, activeTracing: true, })) - .toThrow('You can enable active tracing only for canaries that use version `syn-nodejs-2.0` or later for their canary runtime.'); + .toThrow('You can only enable active tracing for canaries that use canary runtime version `syn-nodejs-2.0` or later.'); }); test('environment variables can be specified', () => {