Skip to content
v2.275.0

AppSyncLambdaDataSource ​

An AppSync datasource backed by a Lambda function.

Example ​

ts
import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const lambdaDs: lambda.Function;

const api = new appsync.EventApi(this, 'EventApiLambda', {
  apiName: 'LambdaEventApi',
});

const dataSource = api.addLambdaDataSource('lambdads', lambdaDs);
python
import aws_cdk.aws_lambda as lambda_

# lambda_ds: lambda.Function


api = appsync.EventApi(self, "EventApiLambda",
    api_name="LambdaEventApi"
)

data_source = api.add_lambda_data_source("lambdads", lambda_ds)
java
import software.amazon.awscdk.services.lambda.*;

Function lambdaDs;


EventApi api = EventApi.Builder.create(this, "EventApiLambda")
        .apiName("LambdaEventApi")
        .build();

AppSyncLambdaDataSource dataSource = api.addLambdaDataSource("lambdads", lambdaDs);
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;

Function lambdaDs;


var api = new EventApi(this, "EventApiLambda", new EventApiProps {
    ApiName = "LambdaEventApi"
});

var dataSource = api.AddLambdaDataSource("lambdads", lambdaDs);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"

var lambdaDs Function


api := appsync.NewEventApi(this, jsii.String("EventApiLambda"), &EventApiProps{
	ApiName: jsii.String("LambdaEventApi"),
})

dataSource := api.AddLambdaDataSource(jsii.String("lambdads"), lambdaDs)

Initializer ​

ts
new AppSyncLambdaDataSource(scope: Construct, id: string, props: AppSyncLambdaDataSourceProps)
python
AppSyncLambdaDataSource(scope: Construct, id: str, props: AppSyncLambdaDataSourceProps)
java
new AppSyncLambdaDataSource(Construct scope, String id, AppSyncLambdaDataSourceProps props)
csharp
new AppSyncLambdaDataSource(Construct scope, string id, AppSyncLambdaDataSourceProps props)
go
NewAppSyncLambdaDataSource(Scope Construct, Id *string, Props AppSyncLambdaDataSourceProps)

Construct Props ​

The API to attach this data source to.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= None#
The description of the data source.
lambdaFunctionIFunctionlambda_functionIFunctionlambdaFunctionIFunctionLambdaFunctionIFunctionLambdaFunctionIFunctionrequired#
The Lambda function to call to interact with this data source.
nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string#
The name of the data source.

Default: id of data source

The only allowed pattern is: {[_A-Za-z][_0-9A-Za-z]*}. Any invalid characters will be automatically removed.

serviceRoleoptionalIRoleservice_roleoptionalIRoleserviceRoleoptionalIRoleServiceRoleoptionalIRoleServiceRoleoptionalIRole#
The IAM service role to be assumed by AppSync to interact with the data source.

Default: Create a new role

Properties ​

grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#
The principal of the data source to be IGrantable.
namestringnamestrnameStringNamestringName*string#
The name of the data source.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
The underlying CFN data source resource.

Methods ​

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining