Function

class Function : KotlinCustomResource

Provides an AppSync Function.

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.appsync.GraphQLApi;
import com.pulumi.aws.appsync.GraphQLApiArgs;
import com.pulumi.aws.appsync.DataSource;
import com.pulumi.aws.appsync.DataSourceArgs;
import com.pulumi.aws.appsync.inputs.DataSourceHttpConfigArgs;
import com.pulumi.aws.appsync.Function;
import com.pulumi.aws.appsync.FunctionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var exampleGraphQLApi = new GraphQLApi("exampleGraphQLApi", GraphQLApiArgs.builder()
.authenticationType("API_KEY")
.schema("""
type Mutation {
putPost(id: ID!, title: String!): Post
}
type Post {
id: ID!
title: String!
}
type Query {
singlePost(id: ID!): Post
}
schema {
query: Query
mutation: Mutation
}
""")
.build());
var exampleDataSource = new DataSource("exampleDataSource", DataSourceArgs.builder()
.apiId(exampleGraphQLApi.id())
.name("example")
.type("HTTP")
.httpConfig(DataSourceHttpConfigArgs.builder()
.endpoint("http://example.com")
.build())
.build());
var exampleFunction = new Function("exampleFunction", FunctionArgs.builder()
.apiId(exampleGraphQLApi.id())
.dataSource(exampleDataSource.name())
.name("example")
.requestMappingTemplate("""
{
"version": "2018-05-29",
"method": "GET",
"resourcePath": "/",
"params":{
"headers": $utils.http.copyheaders($ctx.request.headers)
}
}
""")
.responseMappingTemplate("""
#if($ctx.result.statusCode == 200)
$ctx.result.body
#else
$utils.appendError($ctx.result.body, $ctx.result.statusCode)
#end
""")
.build());
}
}

With Code

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.appsync.Function;
import com.pulumi.aws.appsync.FunctionArgs;
import com.pulumi.aws.appsync.inputs.FunctionRuntimeArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Function("example", FunctionArgs.builder()
.apiId(aws_appsync_graphql_api.example().id())
.dataSource(aws_appsync_datasource.example().name())
.name("example")
.code(Files.readString(Paths.get("some-code-dir")))
.runtime(FunctionRuntimeArgs.builder()
.name("APPSYNC_JS")
.runtimeVersion("1.0.0")
.build())
.build());
}
}

Import

aws_appsync_function can be imported using the AppSync API ID and Function ID separated by -, e.g.,

$ pulumi import aws:appsync/function:Function example xxxxx-yyyyy

Properties

Link copied to clipboard
val apiId: Output<String>

ID of the associated AppSync API.

Link copied to clipboard
val arn: Output<String>

ARN of the Function object.

Link copied to clipboard
val code: Output<String>?

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

Link copied to clipboard
val dataSource: Output<String>

Function data source name.

Link copied to clipboard
val description: Output<String>?

Function description.

Link copied to clipboard
val functionId: Output<String>

Unique ID representing the Function object.

Link copied to clipboard
val functionVersion: Output<String>

Version of the request mapping template. Currently the supported value is 2018-05-29. Does not apply when specifying code.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val maxBatchSize: Output<Int>?

Maximum batching size for a resolver. Valid values are between 0 and 2000.

Link copied to clipboard
val name: Output<String>

Function name. The function name does not have to be unique.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard

Function response mapping template.

Link copied to clipboard
val runtime: Output<FunctionRuntime>?

Describes a runtime used by an AWS AppSync pipeline 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. See Runtime.

Link copied to clipboard

Describes a Sync configuration for a resolver. See Sync Config.

Link copied to clipboard
val urn: Output<String>