Last active
September 24, 2022 17:22
-
-
Save iabhishek07/132a2a82d35d69cf2433bbed8b61965a to your computer and use it in GitHub Desktop.
AppSync CRUD API sls file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: appsync-crud-api | |
frameworkVersion: '2' | |
provider: | |
name: aws | |
runtime: nodejs12.x | |
lambdaHashingVersion: 20201221 | |
region: ${env:REGION, 'ap-south-1'} | |
stage: ${opt:stage, 'dev'} | |
timeout: 30 | |
# Environment variables | |
environment: | |
STAGE: ${self:provider.stage} | |
REGION: ${self:provider.region} | |
SERVICE_NAME: ${self:service}-${self:provider.stage} | |
DYNAMODB: ${self:service}-${self:provider.stage} | |
# IAM statements | |
iamRoleStatements: | |
- Effect: Allow | |
Action: | |
- dynamodb:GetItem | |
- dynamodb:UpdateItem | |
- dynamodb:DeleteItem | |
- dynamodb:PutItem | |
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB}" | |
- Effect: Allow | |
Action: | |
- lambda:invokeFunction | |
Resource: "*" | |
plugins: | |
- serverless-appsync-plugin | |
functions: | |
createBlog: | |
handler: createBlog/index.handler | |
name: createBlog-${self:provider.stage} | |
getBlog: | |
handler: getBlog/index.handler | |
name: getBlog-${self:provider.stage} | |
updateBlog: | |
handler: updateBlog/index.handler | |
name: updateBlog-${self:provider.stage} | |
deleteBlog: | |
handler: deleteBlog/index.handler | |
name: deleteBlog-${self:provider.stage} | |
custom: | |
appSync: | |
name: appsync-crud-api | |
schema: schema.api.graphql | |
authenticationType: API_KEY | |
apiKeys: | |
- apiKey | |
dataSources: | |
- type: AWS_LAMBDA | |
name: createBlog | |
description: 'Lambda' | |
config: | |
functionName: createBlog | |
- type: AWS_LAMBDA | |
name: getBlog | |
description: 'Lambda' | |
config: | |
functionName: getBlog | |
- type: AWS_LAMBDA | |
name: updateBlog | |
description: 'Lambda' | |
config: | |
functionName: updateBlog | |
- type: AWS_LAMBDA | |
name: deleteBlog | |
description: 'Lambda' | |
config: | |
functionName: deleteBlog | |
resources: | |
Resources: | |
BlogsTable: | |
Type: 'AWS::DynamoDB::Table' | |
Properties: | |
AttributeDefinitions: | |
- AttributeName: id | |
AttributeType: S | |
KeySchema: | |
- AttributeName: id | |
KeyType: HASH | |
ProvisionedThroughput: | |
ReadCapacityUnits: 1 | |
WriteCapacityUnits: 1 | |
TableName: ${self:provider.environment.DYNAMODB} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment