Skip to content

Commit

Permalink
ポータルサイトのデータ削除方法明記
Browse files Browse the repository at this point in the history
  • Loading branch information
showwin committed Oct 20, 2024
1 parent 72327b6 commit 002cb37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions contest/terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ $ ssh ishocon@<instance_ip>
```

でインスタンスにSSHできる。
ベンチマーカーを実行すると、スコアを `apigateway_url` に投稿するようになっており、自動的にポータルサイトに結果が表示される。

ポータルサイトに表示されているデータをすべて削除したい場合は以下のコマンドを実行する。

```
$ terraform output -raw apigateway_url | xargs -I {} curl -X "DELETE" "{}teams"
```

## 注意点

Expand Down
3 changes: 2 additions & 1 deletion contest/terraform/module/portal.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ data "aws_iam_policy_document" "lambda" {
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Scan",
"dynamodb:UpdateItem"
"dynamodb:UpdateItem",
"dynamodb:BatchWriteItem",
]
}
statement {
Expand Down
10 changes: 7 additions & 3 deletions contest/terraform/module/portal_lambda.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ def lambda_handler(event, context):

try:
if event["routeKey"] == "DELETE /teams":
table.delete_item(Key={"id": event["pathParameters"]["id"]})
body = "Deleted item " + event["pathParameters"]["id"]
body = responseBody
scan = table.scan()
with table.batch_writer() as batch:
for each in scan["Items"]:
batch.delete_item(
Key={"team": each["team"], "timestamp": each["timestamp"]}
)
body = "Deleted all items"
elif event["routeKey"] == "GET /teams":
body = table.scan()
body = body["Items"]
Expand Down

0 comments on commit 002cb37

Please sign in to comment.