All the DataSources in your AppSync API can be found in serverless.yml under the appSync.dataSources
property. DataSources are defined as key-value objects, the key being the name of the DataSource.
appSync:
dataSources:
myTableDs:
type: AMAZON_DYNAMODB
description: 'My table'
config:
tableName: my-table
tableName
: the name of the DynamoDB tableregion
: the region of the table. Defaults to the stack's regionuseCallerCredentials
: Set totrue
to use AWS Identity and Access Management with this data sourceserviceRoleArn
: The service role ARN for this DataSource. If not provided, a new one will be created.iamRoleStatements
: Statements to use for the generated IAM Role. If not provided, default statements will be used.versioned
: Set totrue
to use Conflict Detection and Resolution with this data source.deltaSyncConfig
:deltaSyncTableName
: The Delta Sync table name.baseTableTTL
: The number of minutes that an Item is stored in the data source. Defaults to43200
deltaSyncTableTTL
: The number of minutes that a Delta Sync log entry is stored in the Delta Sync table. Defaults to1440
appSync:
dataSources:
myFunction:
type: 'AWS_LAMBDA'
config:
function:
timeout: 30
handler: 'functions/myFunction.handler'
serviceRoleArn
: The service role ARN for this DataSource. If not provided, a new one will be created.iamRoleStatements
: Statements to use for the generated IAM Role. If not provided, default statements will be used.function
: A Lambda function definition as you would define it under thefunctions
section of yourserverless.yml
file.functionName
: The name of the function as defined under thefunctions
section of theserverless.yml
filefunctionAlias
: A specific function alias to usefunctionArn
: The function ARN to use for this DataSource.
appSync:
dataSources:
search:
type: 'AMAZON_OPENSEARCH_SERVICE'
config:
endpoint: https://abcdefgh.us-east-1.es.amazonaws.com
endpoint
: The endpoint url to the OpenSearch domainregion
: The region of the OpenSearch domain. Defaults to the stack's region.serviceRoleArn
: The service role ARN for this DataSource. If not provided, a new one will be created.iamRoleStatements
: Statements to use for the generated IAM Role. If not provided, default statements will be used.
appSync:
dataSources:
api:
type: 'HTTP'
config:
endpoint: https://api.example.com
endpoint
: The url of the HTTP endpoint.serviceRoleArn
: The service role ARN for this DataSource. If not provided, a new one will be created.iamRoleStatements
: Statements to use for the generated IAM Role. If not provided, default statements will be used.authorizationConfig
:authorizationType
: The authorization type that the HTTP endpoint requires.AWS_IAM
: The authorization type is Signature Version 4 (SigV4).
awsIamConfig
:signingRegion
: The signing Region for AWS Identity and Access Management authorization. Defaults to the region of the stack.signingServiceName
: The signing service name for AWS Identity and Access Management authorization.
appSync:
dataSources:
myDatabase:
type: 'RELATIONAL_DATABASE'
config:
databaseName: myDatabase
dbClusterIdentifier: Ref: RDSCluster
awsSecretStoreArn: Ref: RDSClusterSecret
serviceRoleArn: !GetAtt RelationalDbServiceRole.Arn
databaseName
: The name of the databaseregion
: The region of the RDS HTTP endpoint. Defaults to the region of the stack.awsSecretStoreArn
: The ARN for database credentials stored in AWS Secrets Manager.dbClusterIdentifier
: Amazon RDS cluster Amazon Resource Name (ARN).schema
: Logical schema name.serviceRoleArn
: The service role ARN for this DataSource. If not provided, a new one will be created.iamRoleStatements
: Statements to use for the generated IAM Role. If not provided, default statements will be used.
appSync:
dataSources:
myEventBus:
type: 'AMAZON_EVENTBRIDGE'
config:
eventBusArn: !GetAtt MyEventBus.Arn
eventBusArn
: The ARN of the event bus
appSync:
dataSources:
api:
type: 'NONE'
You can define your data sources into several files for organizational reasons. You can pass each file into the dataSources
attribute as an array.
dataSources:
- ${file(appsync/dataSources/users.yml)}
- ${file(appsync/dataSources/posts.yml)}