import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
declare const canary: synthetics.Canary;
new cloudwatch.Alarm(this, 'CanaryAlarm', {
metric: canary.metricSuccessPercent(),
evaluationPeriods: 2,
threshold: 90,
comparisonOperator: cloudwatch.ComparisonOperator.LESS_THAN_THRESHOLD,
});
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as assets from '@aws-cdk/assets';
import * as iam from '@aws-cdk/aws-iam';
import * as synthetics from '@aws-cdk/aws-synthetics';
import * as cdk from '@aws-cdk/core';
declare const dockerImage: cdk.DockerImage;
declare const grantable: iam.IGrantable;
declare const localBundling: cdk.ILocalBundling;
const assetCode = new synthetics.AssetCode('assetPath', /* all optional props */ {
assetHash: 'assetHash',
assetHashType: cdk.AssetHashType.SOURCE,
bundling: {
image: dockerImage,
// the properties below are optional
command: ['command'],
entrypoint: ['entrypoint'],
environment: {
environmentKey: 'environment',
},
local: localBundling,
outputType: cdk.BundlingOutput.ARCHIVED,
securityOpt: 'securityOpt',
user: 'user',
volumes: [{
containerPath: 'containerPath',
hostPath: 'hostPath',
// the properties below are optional
consistency: cdk.DockerVolumeConsistency.CONSISTENT,
}],
workingDirectory: 'workingDirectory',
},
exclude: ['exclude'],
follow: assets.FollowMode.NEVER,
followSymlinks: cdk.SymlinkFollowMode.NEVER,
ignoreMode: cdk.IgnoreMode.GLOB,
readers: [grantable],
sourceHash: 'sourceHash',
});
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as s3 from '@aws-cdk/aws-s3';
import * as synthetics from '@aws-cdk/aws-synthetics';
declare const bucket: s3.Bucket;
const s3Code = new synthetics.S3Code(bucket, 'key', /* all optional props */ 'objectVersion');
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as codedeploy from '@aws-cdk/aws-codedeploy';
const cfnDeploymentConfig = new codedeploy.CfnDeploymentConfig(this, 'MyCfnDeploymentConfig', /* all optional props */ {
computePlatform: 'computePlatform',
deploymentConfigName: 'deploymentConfigName',
minimumHealthyHosts: {
type: 'type',
value: 123,
},
trafficRoutingConfig: {
type: 'type',
// the properties below are optional
timeBasedCanary: {
canaryInterval: 123,
canaryPercentage: 123,
},
timeBasedLinear: {
linearInterval: 123,
linearPercentage: 123,
},
},
});
// To supply the code inline:
new synthetics.Canary(this, 'Inline Canary', {
test: synthetics.Test.custom({
code: synthetics.Code.fromInline('/* Synthetics handler code */'),
handler: 'index.handler', // must be 'index.handler'
}),
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3,
});
// To supply the code from your local filesystem:
new synthetics.Canary(this, 'Asset Canary', {
test: synthetics.Test.custom({
code: synthetics.Code.fromAsset(path.join(__dirname, 'canary')),
handler: 'index.handler', // must end with '.handler'
}),
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3,
});
// To supply the code from a S3 bucket:
import * as s3 from '@aws-cdk/aws-s3';
const bucket = new s3.Bucket(this, 'Code Bucket');
new synthetics.Canary(this, 'Bucket Canary', {
test: synthetics.Test.custom({
code: synthetics.Code.fromBucket(bucket, 'canary.zip'),
handler: 'index.handler', // must end with '.handler'
}),
runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_3_3,
});