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, "RelationalDatabaseConfig" : RelationalDatabaseConfig } }
YAML
Type: "AWS::AppSync::DataSource" Properties: Type:StringDescription:StringServiceRoleArn:StringLambdaConfig: LambdaConfig ApiId:StringName:StringDynamoDBConfig: DynamoDBConfig ElasticsearchConfig: ElasticsearchConfig HttpConfig: HttpConfig RelationalDatabaseConfig: RelationalDatabaseConfig
Properties
Type-
Mandatory resource to return data from in customer AWS account. For a complete list of values, see CreateDataSource in the AWS AppSync API Reference for more information.
You can also specify
NONEto use local resolvers. See Local Resolvers Tutorial in the AWS AppSync Developer Guide 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-
The Amazon Resource Name (ARN) of the IAM role which the data source will use to connect to a resource.
Required: Conditional. Required if
Typeis specified asAWS_LAMBDA,AMAZON_DYNAMODB, orAMAZON_ELASTICSEARCH.Type: String
Update requires: No interruption
LambdaConfig-
A valid ARN of a Lambda function in your account.
Required: No
Type: 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: 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 DataSource.
Required: No
Type: HttpConfig
Update requires: No interruption
RelationalDatabaseConfig-
Relational Database configuration of the relational database data source.
Required: No
Type: RelationalDatabaseConfig
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
-
CreateDataSource operation in the AWS AppSync API Reference
