Class FunctionCode
Represents the function's source code.
Inheritance
Namespace: Amazon.CDK.AWS.CloudFront
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class FunctionCode : DeputyBase
Syntax (vb)
Public MustInherit Class FunctionCode
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
Bucket s3Bucket;
// Add a cloudfront Function to a Distribution
var cfFunction = new Function(this, "Function", new FunctionProps {
Code = FunctionCode.FromInline("function handler(event) { return event.request }"),
Runtime = FunctionRuntime.JS_2_0
});
new Distribution(this, "distro", new DistributionProps {
DefaultBehavior = new BehaviorOptions {
Origin = new S3Origin(s3Bucket),
FunctionAssociations = new [] { new FunctionAssociation {
Function = cfFunction,
EventType = FunctionEventType.VIEWER_REQUEST
} }
}
});
Synopsis
Constructors
FunctionCode() | |
FunctionCode(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
FunctionCode(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
FromFile(IFileCodeOptions) | Code from external file for function. |
FromInline(String) | Inline code for function. |
Render() | renders the function code. |
Constructors
FunctionCode()
protected FunctionCode()
FunctionCode(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected FunctionCode(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
FunctionCode(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected FunctionCode(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
FromFile(IFileCodeOptions)
Code from external file for function.
public static FunctionCode FromFile(IFileCodeOptions options)
Parameters
- options IFileCodeOptions
the options for the external file.
Returns
code object with contents from file.
FromInline(String)
Inline code for function.
public static FunctionCode FromInline(string code)
Parameters
- code System.String
The actual function code.
Returns
code object with inline code.
Render()
renders the function code.
public abstract string Render()
Returns
System.String