-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals.tf
125 lines (121 loc) · 3.82 KB
/
locals.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
locals {
gsi_name = "GSI1"
name = "${var.name}_${var.environment}"
appsync = {
functions = {
batchGetMaidoTablePrices = {
data_source = aws_appsync_datasource.dynamodb.name
extra_data = {
table_name = aws_dynamodb_table.this.name
}
}
putCognitoUser = {
data_source = aws_appsync_datasource.http["cognito_idp"].name
extra_data = {
user_pool_id = aws_cognito_user_pool.this.id
}
}
putUserTable = {
data_source = aws_appsync_datasource.dynamodb.name
}
# putOrderTable = {
# data_source = aws_appsync_datasource.dynamodb.name
# }
putQueueCreateStripeCustomer = {
data_source = aws_appsync_datasource.http["sqs"].name
extra_data = {
account_id = data.aws_caller_identity.current.account_id
queue_name = aws_sqs_queue.target.name
}
}
# putStripePaymentMethod = {
# data_source = aws_appsync_datasource.lambda["stripe_update_payment_method"].name
# }
}
resolvers = {
pipeline = [
{
field = "onboardUser"
type = "mutation"
function_keys = ["putCognitoUser", "putQueueCreateStripeCustomer"]
},
# {
# field = "createPayment"
# type = "mutation"
# function_keys = ["batchGetMaidoTablePrices", "createStripePayment"]
# }
]
unit = [
{
field = "getMaidoTable"
type = "query"
data_source = aws_appsync_datasource.dynamodb.name
},
{
field = "batchGetMaidoTablePrices"
type = "query"
data_source = aws_appsync_datasource.dynamodb.name
extra_data = {
table_name = aws_dynamodb_table.this.name
}
},
# {
# field = "putStripePaymentMethod"
# type = "mutation"
# data_source = aws_appsync_datasource.lambda["stripe_update_payment_method"].name
# },
{
field = "queryMaidoTablesByGSI1"
type = "query"
data_source = aws_appsync_datasource.dynamodb.name
}
]
}
}
lambdas = {
stripe_onboarding = {
description = "Onboards customers with the Stripe API and DynamoDB"
timeout = 10
environment_variables = {
DYNAMODB_TABLE_NAME = aws_dynamodb_table.this.name
STRIPE_API_KEY = aws_ssm_parameter.stripe_api_key.value
SQS_QUEUE_URL = aws_sqs_queue.target.url
USER_POOL_ID = aws_cognito_user_pool.this.id
}
trigger = "sqs"
iam_statements = {
cognito = {
actions = ["cognito-idp:AdminUpdateUserAttributes"]
resources = [aws_cognito_user_pool.this.arn]
}
dynamodb = {
actions = ["dynamodb:BatchWriteItem"]
resources = [aws_dynamodb_table.this.arn]
}
sqs = {
actions = ["sqs:DeleteMessage", "sqs:DeleteMessageBatch", "sqs:GetQueueAttributes", "sqs:ReceiveMessage"]
resources = [aws_sqs_queue.target.arn]
}
}
}
# stripe_update_payment_method = {
# description = "Creates a default payment method for a customer with the Stripe API"
# timeout = 10
# environment_variables = {
# STRIPE_API_KEY = aws_ssm_parameter.stripe_api_key.value
# }
# trigger = "appsync"
# iam_statements = {}
# }
}
maps = {
resolvers = {
pipeline = {
for resolver in local.appsync.resolvers.pipeline : lower("${resolver.type}_${resolver.field}") => resolver
}
unit = {
for resolver in local.appsync.resolvers.unit : lower("${resolver.type}_${resolver.field}") => resolver
}
}
}
}