Skip to content

Commit b96e40d

Browse files
Jaccokeetonian
authored andcommitted
feat(SimpleTable): make PAY_PER_REQUEST default billing mode (aws#705)
1 parent 40445a1 commit b96e40d

21 files changed

+30
-103
lines changed

samtranslator/model/dynamodb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ class DynamoDBTable(Resource):
1010
'GlobalSecondaryIndexes': PropertyType(False, list_of(is_type(dict))),
1111
'KeySchema': PropertyType(False, list_of(is_type(dict))),
1212
'LocalSecondaryIndexes': PropertyType(False, list_of(is_type(dict))),
13-
'ProvisionedThroughput': PropertyType(True, dict_of(is_str(), one_of(is_type(int), is_type(dict)))),
13+
'ProvisionedThroughput': PropertyType(False, dict_of(is_str(), one_of(is_type(int), is_type(dict)))),
1414
'StreamSpecification': PropertyType(False, is_type(dict)),
1515
'TableName': PropertyType(False, one_of(is_str(), is_type(dict))),
1616
'Tags': PropertyType(False, list_of(is_type(dict))),
17-
'SSESpecification': PropertyType(False, is_type(dict))
17+
'SSESpecification': PropertyType(False, is_type(dict)),
18+
'BillingMode': PropertyType(False, is_str())
1819
}
1920

2021
runtime_attrs = {

samtranslator/model/sam_resources.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,9 @@ def _construct_dynamodb_table(self):
517517
}]
518518

519519
if self.ProvisionedThroughput:
520-
provisioned_throughput = self.ProvisionedThroughput
520+
dynamodb_table.ProvisionedThroughput = self.ProvisionedThroughput
521521
else:
522-
provisioned_throughput = {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
523-
524-
dynamodb_table.ProvisionedThroughput = provisioned_throughput
522+
dynamodb_table.BillingMode = 'PAY_PER_REQUEST'
525523

526524
if self.SSESpecification:
527525
dynamodb_table.SSESpecification = self.SSESpecification

tests/translator/output/aws-cn/depends_on.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@
114114
"MySamTable": {
115115
"Type": "AWS::DynamoDB::Table",
116116
"Properties": {
117-
"ProvisionedThroughput": {
118-
"WriteCapacityUnits": 5,
119-
"ReadCapacityUnits": 5
120-
},
117+
"BillingMode": "PAY_PER_REQUEST",
121118
"AttributeDefinitions": [
122119
{
123120
"AttributeName": "id",

tests/translator/output/aws-cn/globals_for_simpletable.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"MinimalTable": {
44
"Type": "AWS::DynamoDB::Table",
55
"Properties": {
6-
"ProvisionedThroughput": {
7-
"WriteCapacityUnits": 5,
8-
"ReadCapacityUnits": 5
9-
},
6+
"BillingMode": "PAY_PER_REQUEST",
107
"SSESpecification": {
118
"SSEEnabled": true
129
},

tests/translator/output/aws-cn/simple_table_with_extra_tags.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"MinimalTableWithTags": {
44
"Type": "AWS::DynamoDB::Table",
55
"Properties": {
6-
"ProvisionedThroughput": {
7-
"WriteCapacityUnits": 5,
8-
"ReadCapacityUnits": 5
9-
},
6+
"BillingMode": "PAY_PER_REQUEST",
107
"AttributeDefinitions": [
118
{
129
"AttributeName": "id",

tests/translator/output/aws-cn/simple_table_with_table_name.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
"Type": "AWS::DynamoDB::Table",
55
"Properties": {
66
"TableName": "MySimpleTable",
7-
"ProvisionedThroughput": {
8-
"WriteCapacityUnits": 5,
9-
"ReadCapacityUnits": 5
10-
},
7+
"BillingMode": "PAY_PER_REQUEST",
118
"AttributeDefinitions": [
129
{
1310
"AttributeName": "id",
@@ -28,10 +25,7 @@
2825
"TableName": {
2926
"Ref": "MySimpleTableParameter"
3027
},
31-
"ProvisionedThroughput": {
32-
"WriteCapacityUnits": 5,
33-
"ReadCapacityUnits": 5
34-
},
28+
"BillingMode": "PAY_PER_REQUEST",
3529
"AttributeDefinitions": [
3630
{
3731
"AttributeName": "id",
@@ -52,10 +46,7 @@
5246
"TableName": {
5347
"Fn::Sub": "${AWS::StackName}MySimpleTable"
5448
},
55-
"ProvisionedThroughput": {
56-
"WriteCapacityUnits": 5,
57-
"ReadCapacityUnits": 5
58-
},
49+
"BillingMode": "PAY_PER_REQUEST",
5950
"AttributeDefinitions": [
6051
{
6152
"AttributeName": "id",

tests/translator/output/aws-cn/simpletable.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"MinimalTable": {
44
"Type": "AWS::DynamoDB::Table",
55
"Properties": {
6-
"ProvisionedThroughput": {
7-
"WriteCapacityUnits": 5,
8-
"ReadCapacityUnits": 5
9-
},
6+
"BillingMode": "PAY_PER_REQUEST",
107
"AttributeDefinitions": [
118
{
129
"AttributeName": "id",

tests/translator/output/aws-cn/simpletable_with_sse.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"TableWithSSE": {
44
"Type": "AWS::DynamoDB::Table",
55
"Properties": {
6-
"ProvisionedThroughput": {
7-
"WriteCapacityUnits": 5,
8-
"ReadCapacityUnits": 5
9-
},
6+
"BillingMode": "PAY_PER_REQUEST",
107
"SSESpecification": {
118
"SSEEnabled": true
129
},

tests/translator/output/aws-us-gov/depends_on.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@
114114
"MySamTable": {
115115
"Type": "AWS::DynamoDB::Table",
116116
"Properties": {
117-
"ProvisionedThroughput": {
118-
"WriteCapacityUnits": 5,
119-
"ReadCapacityUnits": 5
120-
},
117+
"BillingMode": "PAY_PER_REQUEST",
121118
"AttributeDefinitions": [
122119
{
123120
"AttributeName": "id",

tests/translator/output/aws-us-gov/globals_for_simpletable.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"MinimalTable": {
44
"Type": "AWS::DynamoDB::Table",
55
"Properties": {
6-
"ProvisionedThroughput": {
7-
"WriteCapacityUnits": 5,
8-
"ReadCapacityUnits": 5
9-
},
6+
"BillingMode": "PAY_PER_REQUEST",
107
"SSESpecification": {
118
"SSEEnabled": true
129
},

0 commit comments

Comments
 (0)