Skip to content

Instantly share code, notes, and snippets.

@chapimenge3
Created December 4, 2022 17:13
Show Gist options
  • Save chapimenge3/f646d592c92d9eade916c34288307461 to your computer and use it in GitHub Desktop.
Save chapimenge3/f646d592c92d9eade916c34288307461 to your computer and use it in GitHub Desktop.
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