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 Elasticsearch
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" : { "ApiId" :
String
, "Description" :String
, "DynamoDBConfig" :DynamoDBConfig
, "ElasticsearchConfig" :ElasticsearchConfig
, "HttpConfig" :HttpConfig
, "LambdaConfig" :LambdaConfig
, "Name" :String
, "RelationalDatabaseConfig" :RelationalDatabaseConfig
, "ServiceRoleArn" :String
, "Type" :String
} }
YAML
Type: AWS::AppSync::DataSource Properties: ApiId:
String
Description:String
DynamoDBConfig:DynamoDBConfig
ElasticsearchConfig:ElasticsearchConfig
HttpConfig:HttpConfig
LambdaConfig:LambdaConfig
Name:String
RelationalDatabaseConfig:RelationalDatabaseConfig
ServiceRoleArn:String
Type:String
Properties
ApiId
-
Unique AWS AppSync GraphQL API identifier where this data source will be created.
Required: Yes
Type: String
Update requires: Replacement
Description
-
The description of the data source.
Required: No
Type: String
Update requires: No interruption
DynamoDBConfig
-
AwsRegion and TableName for an Amazon DynamoDB table in your account.
Required: No
Type: DynamoDBConfig
Update requires: No interruption
ElasticsearchConfig
-
AwsRegion and Endpoints for an Amazon Elasticsearch Service domain in your account.
Required: No
Type: ElasticsearchConfig
Update requires: No interruption
HttpConfig
-
Endpoints for an HTTP data source.
Required: No
Type: HttpConfig
Update requires: No interruption
LambdaConfig
-
An ARN of a Lambda function in valid ARN format. This can be the ARN of a Lambda function that exists in the current account or in another account.
Required: No
Type: LambdaConfig
Update requires: No interruption
Name
-
Friendly name for you to identify your AppSync data source after creation.
Required: Yes
Type: String
Update requires: Replacement
RelationalDatabaseConfig
-
Relational Database configuration of the relational database data source.
Required: No
Type: RelationalDatabaseConfig
Update requires: No interruption
ServiceRoleArn
-
The AWS IAM service role ARN for the data source. The system assumes this role when accessing the data source.
Required if
Type
is specified asAWS_LAMBDA
,AMAZON_DYNAMODB
, orAMAZON_ELASTICSEARCH
.Required: Conditional
Type: String
Update requires: No interruption
Type
-
The type of the data source.
-
AMAZON_DYNAMODB: The data source is an Amazon DynamoDB table.
-
AMAZON_ELASTICSEARCH: The data source is an Amazon Elasticsearch Service domain.
-
AWS_LAMBDA: The data source is an AWS Lambda function.
-
NONE: There is no data source. This type is used when you wish to invoke a GraphQL operation without connecting to a data source, such as performing data transformation with resolvers or triggering a subscription to be invoked from a mutation.
-
HTTP: The data source is an HTTP endpoint.
-
RELATIONAL_DATABASE: The data source is a relational database.
Required: Yes
Type: String
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.
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 parameter.
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
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" } } } } } }
See also
-
CreateDataSource operation in the AWS AppSync API Reference.