Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Last active August 16, 2019 19:24
Show Gist options
  • Save ahmetkucukoglu/918ed6445d3c1688b63aef6d59f0a131 to your computer and use it in GitHub Desktop.
Save ahmetkucukoglu/918ed6445d3c1688b63aef6d59f0a131 to your computer and use it in GitHub Desktop.
serverless.yml v2
service: ads-api
custom:
tableName: AdsTable
provider:
name: aws
runtime: nodejs10.x
region: eu-central-1
profile: serverlessuser
apiKeys:
- AdsAPIKey
environment:
TABLE_NAME: ${self:custom.tableName}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- "Fn::GetAtt": AdsDynamoDBTable.Arn
functions:
create:
handler: create.create
events:
- http:
path: api/ads
method: post
private: true
request:
schema:
application/json: ${file(create_request.json)}
update:
handler: update.update
events:
- http:
path: api/ads/{id}
method: put
private: true
request:
schema:
application/json: ${file(update_request.json)}
delete:
handler: delete.delete
events:
- http:
path: api/ads/{id}
method: delete
private: true
getAll:
handler: getAll.getAll
events:
- http:
path: api/ads
method: get
private: true
getById:
handler: getById.getById
events:
- http:
path: api/ads/{id}
method: get
private: true
resources:
Resources:
AdsDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.tableName}
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment