AWS::AppSync::FunctionConfiguration - AWS CloudFormation

AWS::AppSync::FunctionConfiguration

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.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::AppSync::FunctionConfiguration", "Properties" : { "ApiId" : String, "Code" : String, "CodeS3Location" : String, "DataSourceName" : String, "Description" : String, "FunctionVersion" : String, "MaxBatchSize" : Integer, "Name" : String, "RequestMappingTemplate" : String, "RequestMappingTemplateS3Location" : String, "ResponseMappingTemplate" : String, "ResponseMappingTemplateS3Location" : String, "Runtime" : AppSyncRuntime, "SyncConfig" : SyncConfig } }

YAML

Type: AWS::AppSync::FunctionConfiguration Properties: ApiId: String Code: String CodeS3Location: String DataSourceName: String Description: String FunctionVersion: String MaxBatchSize: Integer Name: String RequestMappingTemplate: String RequestMappingTemplateS3Location: String ResponseMappingTemplate: String ResponseMappingTemplateS3Location: String Runtime: AppSyncRuntime SyncConfig: SyncConfig

Properties

ApiId

The AWS AppSync GraphQL API that you want to attach using this function.

Required: Yes

Type: String

Update requires: Replacement

Code

The resolver code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS.

Required: No

Type: String

Update requires: No interruption

CodeS3Location

The Amazon S3 endpoint.

Required: No

Type: String

Update requires: No interruption

DataSourceName

The name of data source this function will attach.

Required: Yes

Type: String

Update requires: No interruption

Description

The Function description.

Required: No

Type: String

Update requires: No interruption

FunctionVersion

The version of the request mapping template. Currently, only the 2018-05-29 version of the template is supported.

Required: No

Type: String

Update requires: No interruption

MaxBatchSize

The maximum number of resolver request inputs that will be sent to a single AWS Lambda function in a BatchInvoke operation.

Required: No

Type: Integer

Update requires: No interruption

Name

The name of the function.

Required: Yes

Type: String

Update requires: No interruption

RequestMappingTemplate

The Function request mapping template. Functions support only the 2018-05-29 version of the request mapping template.

Required: No

Type: String

Update requires: No interruption

RequestMappingTemplateS3Location

Describes a Sync configuration for a resolver.

Contains information on which Conflict Detection, as well as Resolution strategy, should be performed when the resolver is invoked.

Required: No

Type: String

Update requires: No interruption

ResponseMappingTemplate

The Function response mapping template.

Required: No

Type: String

Update requires: No interruption

ResponseMappingTemplateS3Location

The location of a response mapping template in an Amazon S3 bucket. Use this if you want to provision with a template file in Amazon S3 rather than embedding it in your CloudFormation template.

Required: No

Type: String

Update requires: No interruption

Runtime

Describes a runtime used by an AWS AppSync resolver or AWS AppSync function. Specifies the name and version of the runtime to use. Note that if a runtime is specified, code must also be specified.

Required: No

Type: AppSyncRuntime

Update requires: No interruption

SyncConfig

Describes a Sync configuration for a resolver.

Specifies which Conflict Detection strategy and Resolution strategy to use when the resolver is invoked.

Required: No

Type: SyncConfig

Update requires: No interruption

Return values

Ref

When you pass the logical ID of an AWS::AppSync::FunctionConfiguration resource to the intrinsic Ref function, the function returns the ARN of the FunctionConfiguration, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/functions/functionid.

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using Fn::GetAtt, see Fn::GetAtt.

DataSourceName

The name of data source this function will attach.

FunctionArn

ARN of the function, such as arn:aws:appsync:us-east-1:123456789012:apis/graphqlapiid/functions/functionId.

FunctionId

The unique ID of this function.

Name

The name of the function.

Examples

Function Creation Example

The following example creates a function and associates it with an existing GraphQL API and a data source by passing the GraphQL API ID and data source name as a parameter.

YAML

Parameters: graphQlApiId: Type: String dataSourceName: Type: String name: Type: String description: Type: String functionVersion: Type: String requestMappingTemplateS3LocationInput: Type: String responseMappingTemplateS3LocationInput: Type: String Resources: FunctionConfiguration: Type: AWS::AppSync::FunctionConfiguration Properties: ApiId: Ref: graphQlApiId Name: Ref: name Description: Ref: description DataSourceName: Ref: dataSourceName FunctionVersion: Ref: functionVersion RequestMappingTemplateS3Location: Ref: requestMappingTemplateS3LocationInput ResponseMappingTemplateS3Location: Ref: responseMappingTemplateS3LocationInput

JSON

{ "Parameters": { "graphQlApiId": { "Type": "String" }, "name": { "Type": "String" }, "description": { "Type": "String" }, "dataSourceName": { "Type": "String" }, "functionVersion": { "Type": "String" }, "requestMappingTemplateS3LocationInput": { "Type": "String" }, "responseMappingTemplateS3LocationInput": { "Type": "String" } }, "Resources": { "FunctionConfiguration": { "Type": "AWS::AppSync::FunctionConfiguration", "Properties": { "ApiId": { "Ref": "graphQlApiId" }, "Name": { "Ref": "name" }, "Description": { "Ref": "description" }, "FunctionVersion": { "Ref": "functionVersion" }, "DataSourceName": { "Ref": "dataSourceName" }, "RequestMappingTemplateS3Location": { "Ref": "requestMappingTemplateS3LocationInput" }, "ResponseMappingTemplateS3Location": { "Ref": "responseMappingTemplateS3LocationInput" } } } } }

See also