Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ $ terraform apply
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.49 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.49 |

## Modules

Expand Down
4 changes: 2 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.49 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.49 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.0 |

## Modules
Expand Down
15 changes: 13 additions & 2 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ provider "aws" {
region = "eu-west-1"

# Make it faster by skipping something
skip_get_ec2_platforms = true
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
Expand All @@ -16,7 +15,6 @@ provider "aws" {
alias = "us-east-1"

# Make it faster by skipping something
skip_get_ec2_platforms = true
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
Expand Down Expand Up @@ -251,6 +249,19 @@ EOF
"None",
]
}

"Query.user" = {
kind = "PIPELINE"
type = "Query"
field = "user"
runtime = {
name = "APPSYNC_JS"
}
code = file("src/index.js")
functions = [
"None",
]
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions examples/complete/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ type Post {
title: String!
}

type User {
id: ID!
name: String
}

type Query {
singlePost(id: ID!): Post
none(dummyString: String!): String!
user(id: ID!): User
}

schema {
Expand Down
10 changes: 10 additions & 0 deletions examples/complete/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// For more examples, refer this doc: https://docs.aws.amazon.com/appsync/latest/devguide/configuring-resolvers-js.html
import { util } from "@aws-appsync/utils";

export function request(ctx) {
return {};
}

export function response(ctx) {
return ctx.result.items;
}
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0"
version = ">= 4.49"
}
random = {
source = "hashicorp/random"
Expand Down
16 changes: 14 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,20 @@ resource "aws_appsync_resolver" "this" {
field = each.value.field
kind = lookup(each.value, "kind", null)

request_template = lookup(each.value, "request_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_request_template : "{}")
response_template = lookup(each.value, "response_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_response_template : "{}")
dynamic "runtime" {
for_each = try([each.value.runtime], [])

content {
name = runtime.value.name
runtime_version = try(runtime.value.runtime_version, "1.0.0")
}
}

# code is required when runtime is APPSYNC_JS
code = try(each.value.kind == "PIPELINE" && each.value.runtime.name == "APPSYNC_JS", false) ? each.value.code : null

request_template = lookup(each.value, "request_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_request_template : try(each.value.kind == "PIPELINE" && each.value.runtime.name == "APPSYNC_JS", false) ? null : "{}")
response_template = lookup(each.value, "response_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_response_template : try(each.value.kind == "PIPELINE" && each.value.runtime.name == "APPSYNC_JS", false) ? null : "{}")

data_source = lookup(each.value, "data_source", null) != null ? aws_appsync_datasource.this[each.value.data_source].name : lookup(each.value, "data_source_arn", null)

Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ output "appsync_domain_hosted_zone_id" {
# Extra
output "appsync_graphql_api_fqdns" {
description = "Map of FQDNs associated with the API (no protocol and path)"
value = { for k, v in try(aws_appsync_graphql_api.this[0].uris, "") : k => regex("://([^/?#]*)?", v)[0] if length(aws_appsync_graphql_api.this) > 0 }
value = { for k, v in try(aws_appsync_graphql_api.this[0].uris, []) : k => regex("://([^/?#]*)?", v)[0] if length(aws_appsync_graphql_api.this) > 0 }
}
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0"
version = ">= 4.49"
}
random = {
source = "hashicorp/random"
Expand Down