Created
December 4, 2022 17:13
-
-
Save chapimenge3/f646d592c92d9eade916c34288307461 to your computer and use it in GitHub Desktop.
https://blog.chapimenge.com/posts/serverless/todo-api-serverless/ with DynamoDB added serverless.yml
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: Todo | |
frameworkVersion: '3' | |
# new | |
custom: | |
tableName: 'todo-table-${self:provider.stage}' | |
provider: | |
name: aws | |
runtime: python3.8 | |
# Totally optional, but it's a good idea to set this | |
stage: dev | |
profile: default # if you are working with different AWS account | |
stackName: todo-stack | |
logRetentionInDays: 14 | |
region: 'us-east-1' # if you are working with different AWS region choose nearest to you | |
# new | |
iam: | |
role: | |
statements: | |
- Effect: Allow | |
Action: | |
- dynamodb:Query | |
- dynamodb:Scan | |
- dynamodb:GetItem | |
- dynamodb:PutItem | |
- dynamodb:UpdateItem | |
- dynamodb:DeleteItem | |
Resource: | |
- Fn::GetAtt: [ TodoTable, Arn ] | |
environment: | |
TODO_TABLE: ${self:custom.tableName} | |
functions: | |
hello: | |
handler: handler.hello | |
events: | |
- httpApi: | |
path: / | |
method: get | |
# new | |
resources: | |
Resources: | |
TodoTable: | |
Type: AWS::DynamoDB::Table | |
Properties: | |
AttributeDefinitions: | |
- AttributeName: todoId | |
AttributeType: S | |
KeySchema: | |
- AttributeName: todoId | |
KeyType: HASH | |
ProvisionedThroughput: | |
ReadCapacityUnits: 1 | |
WriteCapacityUnits: 1 | |
TableName: ${self:custom.tableName} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment