Skip to content

Instantly share code, notes, and snippets.

@bboure
Last active December 26, 2020 21:27
Show Gist options
  • Save bboure/a5a5cec724188ac652757b8cc0667cbf to your computer and use it in GitHub Desktop.
Save bboure/a5a5cec724188ac652757b8cc0667cbf to your computer and use it in GitHub Desktop.
appsync-long-cache-demo-serverless.yml
mappingTemplates:
- type: Query
field: wikipedia
kind: PIPELINE
functions:
- fetchFromCache
- fetchWikipedia
- saveToCache
dataSources:
- type: HTTP
name: wikipedia
description: 'Wikipedia api'
config:
endpoint: https://en.wikipedia.org
- type: AMAZON_DYNAMODB
name: wikicache
description: 'Wikipedia cached titles'
config:
tableName:
Ref: WikipediaTable
functionConfigurations:
- dataSource: wikicache
name: fetchFromCache
- dataSource: wikicache
name: saveToCache
- dataSource: wikipedia
name: fetchWikipedia
resources:
Resources:
WikipediaTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: wikipedia
BillingMode: PAY_PER_REQUEST
TimeToLiveSpecification:
AttributeName: expires_at
Enabled: true
AttributeDefinitions:
- AttributeName: title
AttributeType: S
- AttributeName: expires_at
AttributeType: N
KeySchema:
- AttributeName: title
KeyType: HASH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment