Class Code
Represents source code for an AppSync Function or Resolver.
Namespace: Amazon.CDK.AWS.AppSync
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class Code : DeputyBase
Syntax (vb)
Public MustInherit Class Code Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
EventApi api;
AppSyncLambdaDataSource lambdaDataSource;
// Lambda data source for publish handler
api.AddChannelNamespace("lambda-ns", new ChannelNamespaceOptions {
Code = Code.FromInline("/* event handler code here.*/"),
PublishHandlerConfig = new HandlerConfig {
DataSource = lambdaDataSource
}
});
// Direct Lambda data source for publish handler
api.AddChannelNamespace("lambda-direct-ns", new ChannelNamespaceOptions {
PublishHandlerConfig = new HandlerConfig {
DataSource = lambdaDataSource,
Direct = true
}
});
api.AddChannelNamespace("lambda-direct-async-ns", new ChannelNamespaceOptions {
PublishHandlerConfig = new HandlerConfig {
DataSource = lambdaDataSource,
Direct = true,
LambdaInvokeType = LambdaInvokeType.EVENT
}
});
Synopsis
Constructors
Code() | Represents source code for an AppSync Function or Resolver. |
Methods
Bind(Construct) | Bind source code to an AppSync Function or resolver. |
FromAsset(string, IAssetOptions?) | Loads the function code from a local disk path. |
FromInline(string) | Inline code for AppSync function. |
Constructors
Code()
Represents source code for an AppSync Function or Resolver.
protected Code()
Remarks
ExampleMetadata: infused
Examples
EventApi api;
AppSyncLambdaDataSource lambdaDataSource;
// Lambda data source for publish handler
api.AddChannelNamespace("lambda-ns", new ChannelNamespaceOptions {
Code = Code.FromInline("/* event handler code here.*/"),
PublishHandlerConfig = new HandlerConfig {
DataSource = lambdaDataSource
}
});
// Direct Lambda data source for publish handler
api.AddChannelNamespace("lambda-direct-ns", new ChannelNamespaceOptions {
PublishHandlerConfig = new HandlerConfig {
DataSource = lambdaDataSource,
Direct = true
}
});
api.AddChannelNamespace("lambda-direct-async-ns", new ChannelNamespaceOptions {
PublishHandlerConfig = new HandlerConfig {
DataSource = lambdaDataSource,
Direct = true,
LambdaInvokeType = LambdaInvokeType.EVENT
}
});
Methods
Bind(Construct)
Bind source code to an AppSync Function or resolver.
public abstract ICodeConfig Bind(Construct scope)
Parameters
- scope Construct
Returns
Remarks
ExampleMetadata: infused
FromAsset(string, IAssetOptions?)
Loads the function code from a local disk path.
public static AssetCode FromAsset(string path, IAssetOptions? options = null)
Parameters
- path string
The path to the source code file.
- options IAssetOptions
The path to the source code file.
Returns
Remarks
ExampleMetadata: infused
FromInline(string)
Inline code for AppSync function.
public static InlineCode FromInline(string code)
Parameters
- code string
The actual handler code (the resulting zip file cannot exceed 4MB).
Returns
InlineCode
with inline code.
Remarks
ExampleMetadata: infused