-
Notifications
You must be signed in to change notification settings - Fork 6
/
resolvers.tf
68 lines (55 loc) · 2.33 KB
/
resolvers.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
/**
* Points of interest:
* - Each resolver has an explicit depends_on for the datasource, this is because the datasource doesn't expose its
* name as output so we are forced to reference the datasource_name variable, removing Terraform's ability to infer
* a dependency of this resource on the datasource's creation.
*/
data "local_file" "cloudformation_resolver_template" {
filename = "${path.module}/cloudformation-templates/resolver.json"
}
## List People
data "local_file" "list_people_request_mapping" {
filename = "${path.module}/people-api/resolvers/listPeople-request-mapping-template.txt"
}
data "local_file" "list_people_response_mapping" {
filename = "${path.module}/people-api/resolvers/listPeople-response-mapping-template.txt"
}
resource "aws_cloudformation_stack" "list_people_resolver" {
depends_on = [
"aws_appsync_datasource.people",
"aws_cloudformation_stack.api_schema"
]
name = "${var.appsync_name}-list-people-resolver"
parameters = {
graphQlApiId = "${aws_appsync_graphql_api.people.id}"
dataSourceName = "${var.datasource_name}"
fieldName = "listPeople"
typeName = "Query"
requestMappingTemplate = "${data.local_file.list_people_request_mapping.content}"
responseMappingTemplate = "${data.local_file.list_people_response_mapping.content}"
}
template_body = "${data.local_file.cloudformation_resolver_template.content}"
}
# Create Person
data "local_file" "create_source_request_mapping" {
filename = "${path.module}/people-api/resolvers/createPerson-request-mapping-template.txt"
}
data "local_file" "create_source_response_mapping" {
filename = "${path.module}/people-api/resolvers/createPerson-response-mapping-template.txt"
}
resource "aws_cloudformation_stack" "create_person_resolver" {
depends_on = [
"aws_appsync_datasource.people",
"aws_cloudformation_stack.api_schema"
]
name = "${var.appsync_name}-create-person-resolver"
parameters = {
graphQlApiId = "${aws_appsync_graphql_api.people.id}"
dataSourceName = "${var.datasource_name}"
fieldName = "createPerson"
typeName = "Mutation"
requestMappingTemplate = "${data.local_file.create_source_request_mapping.content}"
responseMappingTemplate = "${data.local_file.create_source_response_mapping.content}"
}
template_body = "${data.local_file.cloudformation_resolver_template.content}"
}