Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::AppSync::DataSource

The AWS::AppSync::DataSource resource creates data sources for resolvers in AWS AppSync to connect to, such as Amazon DynamoDB, AWS Lambda, and Amazon Elasticserach Service. Resolvers use these data sources to fetch data when clients make GraphQL calls.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::AppSync::DataSource", "Properties" : { "Type" : String, "Description" : String, "ServiceRoleArn" : String, "LambdaConfig" : LambdaConfig, "ApiId" : String, "Name" : String, "DynamoDBConfig" : DynamoDBConfig, "ElasticsearchConfig" : ElasticsearchConfig, "HttpConfig" : HttpConfig } }

YAML

Type: "AWS::AppSync::DataSource" Properties: Type: String Description: String ServiceRoleArn: String LambdaConfig: LambdaConfig ApiId: String Name: String DynamoDBConfig: DynamoDBConfig ElasticsearchConfig: ElasticsearchConfig HttpConfig: HttpConfig

Properties

Type

Mandatory resource to return data from in customer AWS account. You can also specify NONE to use Local Resolvers. See Local Resolvers Tutorial for more information.

Required: Yes

Type: String

Update requires: No interruption

Description

Friendly description for this data source.

Required: No

Type: String

Update requires: No interruption

ServiceRoleArn

IAM role ARN which the data source will use to connect to a resource.

Required: No

Type: String

Update requires: No interruption

LambdaConfig

A valid ARN of a Lambda function in your account.

Required: No

Type: AWS AppSync DataSource LambdaConfig

Update requires: No interruption

ApiId

Unique AWS AppSync GraphQL API Identifier where this data source will be created.

Required: Yes

Type: String

Update requires: Replacement

Name

Friendly name for you to identify your AppSync data source after creation.

Required: Yes

Type: String

Update requires: Replacement

DynamoDBConfig

AwsRegion and TableName for an Amazon DynamoDB table in your account.

Required: No

Type: AWS AppSync DataSource DynamoDBConfig

Update requires: No interruption

ElasticsearchConfig

AwsRegion and Endpoints for an Amazon Elasticsearch Service domain in your account.

Required: No

Type: AWS AppSync DataSource ElasticsearchConfig

Update requires: No interruption

HttpConfig

Endpoints for an HTTP DataSource.

Required: No

Type: AWS AppSync DataSource HttpConfig

Update requires: No interruption

Return Values

Ref

When you pass the logical ID of an AWS::AppSync::DataSource resource to the intrinsic Ref function, the function returns the ARN of the Data Source, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/datasources/datasourcename.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

DataSourceArn

The Amazon Resource Name (ARN) of the API key, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/datasources/datasourcename.

Name

Friendly name for you to identify your AppSync data source after creation.

For more information about using Fn::GetAtt, see Fn::GetAtt.

Examples

Data Source creation example

The following example creates a data source and associates it with an existing GraphQL API by passing the GraphQL API Id as a paramater.

JSON

{ "Parameters": { "graphQlApiId": { "Type": "String" }, "dataSourceName": { "Type": "String" }, "dataSourceDescription": { "Type": "String" }, "serviceRoleArn": { "Type": "String" }, "lambdaFunctionArn": { "Type": "String" } }, "Resources": { "DataSource": { "Type": "AWS::AppSync::DataSource", "Properties": { "ApiId": { "Ref": "graphQlApiId" }, "Name": { "Ref": "dataSourceName" }, "Description": { "Ref": "dataSourceDescription" }, "Type": "AWS_LAMBDA", "ServiceRoleArn": { "Ref": "serviceRoleArn" }, "LambdaConfig": { "LambdaFunctionArn": { "Ref": "lambdaFunctionArn" } } } } } }

YAML

Parameters: graphQlApiId: Type: String dataSourceName: Type: String dataSourceDescription: Type: String serviceRoleArn: Type: String lambdaFunctionArn: Type: String Resources: DataSource: Type: AWS::AppSync::DataSource Properties: ApiId: Ref: graphQlApiId Name: Ref: dataSourceName Description: Ref: dataSourceDescription Type: "AWS_LAMBDA" ServiceRoleArn: Ref: serviceRoleArn LambdaConfig: LambdaFunctionArn: Ref: lambdaFunctionArn

See Also