1 | resource "aws_dynamodb_table" "user" { |
2 | name = "user-${random_id.id.hex}" |
3 | billing_mode = "PAY_PER_REQUEST" |
4 | hash_key = "id" |
5 | attribute { |
6 | name = "id" |
7 | type = "S" |
8 | } |
9 | } |
10 | |
11 | resource "aws_dynamodb_table" "friend" { |
12 | name = "friend-${random_id.id.hex}" |
13 | billing_mode = "PAY_PER_REQUEST" |
14 | hash_key = "userId1" |
15 | range_key = "userId2" |
16 | attribute { |
17 | name = "userId1" |
18 | type = "S" |
19 | } |
20 | attribute { |
21 | name = "userId2" |
22 | type = "S" |
23 | } |
24 | } |
25 | |
26 | resource "aws_dynamodb_table" "post" { |
27 | name = "post-${random_id.id.hex}" |
28 | billing_mode = "PAY_PER_REQUEST" |
29 | hash_key = "id" |
30 | attribute { |
31 | name = "id" |
32 | type = "S" |
33 | } |
34 | attribute { |
35 | name = "userId" |
36 | type = "S" |
37 | } |
38 | attribute { |
39 | name = "date" |
40 | type = "N" |
41 | } |
42 | |
43 | global_secondary_index { |
44 | name = "userId" |
45 | hash_key = "userId" |
46 | range_key = "date" |
47 | projection_type = "ALL" |
48 | } |
49 | } |
50 | |
51 | resource "aws_dynamodb_table" "comment" { |
52 | name = "comment-${random_id.id.hex}" |
53 | billing_mode = "PAY_PER_REQUEST" |
54 | hash_key = "id" |
55 | attribute { |
56 | name = "id" |
57 | type = "S" |
58 | } |
59 | attribute { |
60 | name = "postId" |
61 | type = "S" |
62 | } |
63 | attribute { |
64 | name = "date" |
65 | type = "N" |
66 | } |
67 | |
68 | global_secondary_index { |
69 | name = "postId" |
70 | hash_key = "postId" |
71 | range_key = "date" |
72 | projection_type = "ALL" |
73 | } |
74 | } |
75 | |
76 | |
77 | |