Class Code
The code the canary should execute.
Namespace: Amazon.CDK.AWS.Synthetics
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class Code : DeputyBase
Syntax (vb)
Public MustInherit Class Code
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
var canary = new Canary(this, "MyCanary", new CanaryProps {
Schedule = Schedule.Rate(Duration.Minutes(5)),
Test = Test.Custom(new CustomTestOptions {
Code = Code.FromAsset(Join(__dirname, "canary")),
Handler = "index.handler"
}),
Runtime = Runtime.SYNTHETICS_NODEJS_PUPPETEER_6_2,
EnvironmentVariables = new Dictionary<string, string> {
{ "stage", "prod" }
}
});
Synopsis
Constructors
Code() | |
Code(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Code(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
Bind(Construct, String, RuntimeFamily) | Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun. |
FromAsset(String, IAssetOptions) | Specify code from a local path. |
FromBucket(IBucket, String, String) | Specify code from an s3 bucket. |
FromInline(String) | Specify code inline. |
Constructors
Code()
protected Code()
Code(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Code(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Code(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Code(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
Bind(Construct, String, RuntimeFamily)
Called when the canary is initialized to allow this object to bind to the stack, add resources and have fun.
public abstract ICodeConfig Bind(Construct scope, string handler, RuntimeFamily family)
Parameters
- scope Constructs.Construct
The binding scope.
- handler System.String
The binding scope.
- family RuntimeFamily
The binding scope.
Returns
a bound CodeConfig
.
FromAsset(String, IAssetOptions)
Specify code from a local path.
public static AssetCode FromAsset(string assetPath, IAssetOptions options = null)
Parameters
- assetPath System.String
Either a directory or a .zip file.
- options IAssetOptions
Either a directory or a .zip file.
Returns
AssetCode
associated with the specified path.
Remarks
Path must include the folder structure nodejs/node_modules/myCanaryFilename.js
.
FromBucket(IBucket, String, String)
Specify code from an s3 bucket.
public static S3Code FromBucket(IBucket bucket, string key, string objectVersion = null)
Parameters
- bucket IBucket
The S3 bucket.
- key System.String
The object key.
- objectVersion System.String
Optional S3 object version.
Returns
S3Code
associated with the specified S3 object.
Remarks
The object in the s3 bucket must be a .zip file that contains
the structure nodejs/node_modules/myCanaryFilename.js
.
FromInline(String)
Specify code inline.
public static InlineCode FromInline(string code)
Parameters
- code System.String
The actual handler code (limited to 5MB).
Returns
InlineCode
with inline code.