Class Function


  • public class Function
    extends com.pulumi.resources.CustomResource
    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.ArrayList;
     import java.util.Arrays;
     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 GraphQLApi("example", GraphQLApiArgs.builder()
                 .authenticationType("API_KEY")
                 .name("example")
                 .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()
                 .httpConfig(DataSourceHttpConfigArgs.builder()
                     .endpoint("http://example.com")
                     .build())
                 .apiId(example.id())
                 .name("example")
                 .type("HTTP")
                 .build());
     
             var exampleFunction = new Function("exampleFunction", FunctionArgs.builder()
                 .apiId(example.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());
     
         }
     }
     
     
    ### Example Usage 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 com.pulumi.std.StdFunctions;
     import com.pulumi.std.inputs.FileArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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()
                 .runtime(FunctionRuntimeArgs.builder()
                     .name("APPSYNC_JS")
                     .runtimeVersion("1.0.0")
                     .build())
                 .apiId(exampleAwsAppsyncGraphqlApi.id())
                 .dataSource(exampleAwsAppsyncDatasource.name())
                 .name("example")
                 .code(StdFunctions.file(FileArgs.builder()
                     .input("some-code-dir")
                     .build()).result())
                 .build());
     
         }
     }
     
     
    ## Import Using `pulumi import`, import `aws.appsync.Function` using the AppSync API ID and Function ID separated by `-`. For example: ```sh $ pulumi import aws:appsync/function:Function example xxxxx-yyyyy ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Function​(java.lang.String name)  
      Function​(java.lang.String name, FunctionArgs args)  
      Function​(java.lang.String name, FunctionArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> apiId()  
      com.pulumi.core.Output<java.lang.String> arn()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> code()  
      com.pulumi.core.Output<java.lang.String> dataSource()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()  
      com.pulumi.core.Output<java.lang.String> functionId()  
      com.pulumi.core.Output<java.lang.String> functionVersion()  
      static Function get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, FunctionState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> maxBatchSize()  
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> requestMappingTemplate()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> responseMappingTemplate()  
      com.pulumi.core.Output<java.util.Optional<FunctionRuntime>> runtime()  
      com.pulumi.core.Output<java.util.Optional<FunctionSyncConfig>> syncConfig()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Function

        public Function​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Function

        public Function​(java.lang.String name,
                        FunctionArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Function

        public Function​(java.lang.String name,
                        FunctionArgs args,
                        @Nullable
                        com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • apiId

        public com.pulumi.core.Output<java.lang.String> apiId()
        Returns:
        ID of the associated AppSync API.
      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of the Function object.
      • code

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> code()
        Returns:
        Function code that contains the request and response functions. When code is used, the runtime is required. The runtime value must be APPSYNC_JS.
      • dataSource

        public com.pulumi.core.Output<java.lang.String> dataSource()
        Returns:
        Function data source name.
      • description

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> description()
        Returns:
        Function description.
      • functionId

        public com.pulumi.core.Output<java.lang.String> functionId()
        Returns:
        Unique ID representing the Function object.
      • functionVersion

        public com.pulumi.core.Output<java.lang.String> functionVersion()
        Returns:
        Version of the request mapping template. Currently the supported value is `2018-05-29`. Does not apply when specifying `code`.
      • maxBatchSize

        public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> maxBatchSize()
        Returns:
        Maximum batching size for a resolver. Valid values are between `0` and `2000`.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        Function name. The function name does not have to be unique.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • requestMappingTemplate

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> requestMappingTemplate()
        Returns:
        Function request mapping template. Functions support only the 2018-05-29 version of the request mapping template.
      • responseMappingTemplate

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> responseMappingTemplate()
        Returns:
        Function response mapping template.
      • runtime

        public com.pulumi.core.Output<java.util.Optional<FunctionRuntime>> runtime()
        Returns:
        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` Block for details.
      • syncConfig

        public com.pulumi.core.Output<java.util.Optional<FunctionSyncConfig>> syncConfig()
        Returns:
        Sync configuration for a resolver. See `syncConfig` Block for details.
      • get

        public static Function get​(java.lang.String name,
                                   com.pulumi.core.Output<java.lang.String> id,
                                   @Nullable
                                   FunctionState state,
                                   @Nullable
                                   com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.