File tree Expand file tree Collapse file tree 3 files changed +38
-22
lines changed
Expand file tree Collapse file tree 3 files changed +38
-22
lines changed Original file line number Diff line number Diff line change 11from flask import Flask , render_template
2+
3+ from pynamodb .models import Model
4+ from pynamodb .attributes import UnicodeAttribute
5+
26app = Flask (__name__ )
37
8+ class OneTable (Model ):
9+ '''
10+ DynamoDB works best with a single table. This table. Use this table to model
11+ other data requests.
12+ '''
13+ class Meta :
14+ table_name = os .environ ['DYNAMODB_TABLE_NAME' ]
15+
16+ pk = UnicodeAttribute (hash_key = True )
17+ sk = UnicodeAttribute (range_key = True )
18+
419@app .route ("/" )
520def cats ():
621 return render_template ('index.html' )
Original file line number Diff line number Diff line change 11pytest
22Flask
3- requests
3+ requests
4+ pynamodb
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ provider:
66 region : us-west-2
77 deploymentBucket :
88 name : infra.opszero.com
9- # environment:
10- # DYNAMODB_TABLE_NAME: <service_name> -${sls:stage}
9+ environment :
10+ DYNAMODB_TABLE_NAME : ${self:service}} -${sls:stage}
1111 httpApi :
1212 cors : true
1313 # iamRoleStatements:
@@ -66,25 +66,25 @@ package:
6666 patterns :
6767 - ' !node_modules/**'
6868
69- # resources:
70- # Resources:
71- # oneTable:
72- # Type: AWS::DynamoDB::Table
73- # Properties:
74- # TableName: <service_name> -${sls:stage}
75- # AttributeDefinitions:
76- # - AttributeName: pk
77- # AttributeType: S
78- # - AttributeName: sk
79- # AttributeType: S
80- # KeySchema:
81- # - AttributeName: pk
82- # KeyType: HASH
83- # - AttributeName: sk
84- # KeyType: RANGE
85- # ProvisionedThroughput:
86- # ReadCapacityUnits: 3
87- # WriteCapacityUnits: 3
69+ resources :
70+ Resources :
71+ oneTable :
72+ Type : AWS::DynamoDB::Table
73+ Properties :
74+ TableName : ${self:service} -${sls:stage}
75+ AttributeDefinitions :
76+ - AttributeName : pk
77+ AttributeType : S
78+ - AttributeName : sk
79+ AttributeType : S
80+ KeySchema :
81+ - AttributeName : pk
82+ KeyType : HASH
83+ - AttributeName : sk
84+ KeyType : RANGE
85+ ProvisionedThroughput :
86+ ReadCapacityUnits : 1
87+ WriteCapacityUnits : 1
8888# s3bucket:
8989# Type: AWS::S3::Bucket
9090# Properties:
You can’t perform that action at this time.
0 commit comments