// 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 synthetics from '@aws-cdk/aws-synthetics';
const inlineCode = new synthetics.InlineCode('code');
import * as lambda from '@aws-cdk/aws-lambda';
import * as triggers from '@aws-cdk/triggers';
import { Stack } from '@aws-cdk/core';
declare const stack: Stack;
new triggers.TriggerFunction(stack, 'MyTrigger', {
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'index.handler',
code: lambda.Code.fromAsset(__dirname + '/my-trigger'),
});
// 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,
});
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_3_1,
environmentVariables: {
stage: 'prod',
},
});