AWS AppSync Function
This page shows how to write Terraform and CloudFormation for AWS AppSync Function and write them securely.
aws_appsync_function (Terraform)
The Function in AWS AppSync can be configured in Terraform with the resource name aws_appsync_function
. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_appsync_function" "get_game_function" {
api_id = aws_appsync_graphql_api.GuaranteedRateTest.id
data_source = aws_appsync_datasource.ratetest_dynamodb_game_datasource.name
name = "get_cart_function"
request_mapping_template = file("./AppSync/functions/getGame/request-mapping.vtl")
response_mapping_template = file("./AppSync/resolvers/_generic/generic-response-mapping-item-SINGULAR.vtl")
resource "aws_appsync_function" "get_user_function" {
api_id = aws_appsync_graphql_api.MultiCart.id
data_source = aws_appsync_datasource.multicart_dynamodb_user_datasource.name
name = "get_user_function"
request_mapping_template = file("./AppSync/functions/getUser/request-mapping.vtl")
response_mapping_template = file("./AppSync/resolvers/_generic/generic-response-mapping-items-NULL-OR-FIRST.vtl")
resource "aws_appsync_function" "function" {
count = length(var.function)
api_id = element(var.api_id, lookup(var.function[count.index], "api_id"))
data_source = element(var.data_source, lookup(var.function[count.index], "datasource_id"))
name = lookup(var.function[count.index], "name")
description = lookup(var.function[count.index], "description")
resource "aws_appsync_function" "this" {
api_id = var.api_id
data_source = var.data_source
description = var.description
function_version = var.function_version
name = var.name
Parameters
-
api_id
required - string -
arn
optional computed - string -
data_source
required - string -
description
optional - string -
function_id
optional computed - string -
function_version
optional - string -
id
optional computed - string -
name
required - string -
request_mapping_template
required - string -
response_mapping_template
required - string
Explanation in Terraform Registry
Provides an AppSync Function.
AWS::AppSync::FunctionConfiguration (CloudFormation)
The FunctionConfiguration in AppSync can be configured in CloudFormation with the resource name AWS::AppSync::FunctionConfiguration
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
-
ResponseMappingTemplateS3Location
optional - String -
Description
optional - String -
DataSourceName
required - String -
RequestMappingTemplate
optional - String -
ResponseMappingTemplate
optional - String -
FunctionVersion
required - String -
SyncConfig
optional - SyncConfig -
RequestMappingTemplateS3Location
optional - String -
ApiId
required - String -
Name
required - String
Explanation in CloudFormation Registry
The
AWS::AppSync::FunctionConfiguration
resource defines the functions in GraphQL APIs to perform certain operations. You can use pipeline resolvers to attach functions. For more information, see Pipeline Resolvers in the AWS AppSync Developer Guide. Note When you submit an update, AWS CloudFormation updates resources based on differences between what you submit and the stack's current template. To cause this resource to be updated you must change a property value for this resource in the AWS CloudFormation template. Changing the Amazon S3 file content without changing a property value will not result in an update operation. See Update Behaviors of Stack Resources in the AWS CloudFormation User Guide.
Frequently asked questions
What is AWS AppSync Function?
AWS AppSync Function is a resource for AppSync of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS AppSync Function?
For Terraform, the charlieargue/rate-test-karlgolka, charlieargue/multi-cart and mikamakusa/terraform source code examples are useful. See the Terraform Example section for further details.