UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

205 lines 6.99 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Resolver = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides an AppSync Resolver. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.appsync.GraphQLApi("test", { * authenticationType: "API_KEY", * name: "tf-example", * schema: `type Mutation { * \\tputPost(id: ID!, title: String!): Post * } * * type Post { * \\tid: ID! * \\ttitle: String! * } * * type Query { * \\tsinglePost(id: ID!): Post * } * * schema { * \\tquery: Query * \\tmutation: Mutation * } * `, * }); * const testDataSource = new aws.appsync.DataSource("test", { * apiId: test.id, * name: "my_example", * type: "HTTP", * httpConfig: { * endpoint: "http://example.com", * }, * }); * // UNIT type resolver (default) * const testResolver = new aws.appsync.Resolver("test", { * apiId: test.id, * field: "singlePost", * type: "Query", * dataSource: testDataSource.name, * requestTemplate: `{ * \\"version\\": \\"2018-05-29\\", * \\"method\\": \\"GET\\", * \\"resourcePath\\": \\"/\\", * \\"params\\":{ * \\"headers\\": utils.http.copyheaders(ctx.request.headers) * } * } * `, * responseTemplate: `#if(ctx.result.statusCode == 200) * ctx.result.body * #else * utils.appendError(ctx.result.body, ctx.result.statusCode) * #end * `, * cachingConfig: { * cachingKeys: [ * "$context.identity.sub", * "$context.arguments.id", * ], * ttl: 60, * }, * }); * // PIPELINE type resolver * const mutationPipelineTest = new aws.appsync.Resolver("Mutation_pipelineTest", { * type: "Mutation", * apiId: test.id, * field: "pipelineTest", * requestTemplate: "{}", * responseTemplate: "$util.toJson($ctx.result)", * kind: "PIPELINE", * pipelineConfig: { * functions: [ * test1.functionId, * test2.functionId, * test3.functionId, * ], * }, * }); * ``` * * ### JS * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const example = new aws.appsync.Resolver("example", { * type: "Query", * apiId: testAwsAppsyncGraphqlApi.id, * field: "pipelineTest", * kind: "PIPELINE", * code: std.file({ * input: "some-code-dir", * }).then(invoke => invoke.result), * runtime: { * name: "APPSYNC_JS", * runtimeVersion: "1.0.0", * }, * pipelineConfig: { * functions: [test.functionId], * }, * }); * ``` * * ## Import * * Using `pulumi import`, import `aws_appsync_resolver` using the `api_id`, a hyphen, `type`, a hypen and `field`. For example: * * ```sh * $ pulumi import aws:appsync/resolver:Resolver example abcdef123456-exampleType-exampleField * ``` */ class Resolver extends pulumi.CustomResource { /** * Get an existing Resolver resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Resolver(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Resolver. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Resolver.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["apiId"] = state?.apiId; resourceInputs["arn"] = state?.arn; resourceInputs["cachingConfig"] = state?.cachingConfig; resourceInputs["code"] = state?.code; resourceInputs["dataSource"] = state?.dataSource; resourceInputs["field"] = state?.field; resourceInputs["kind"] = state?.kind; resourceInputs["maxBatchSize"] = state?.maxBatchSize; resourceInputs["pipelineConfig"] = state?.pipelineConfig; resourceInputs["region"] = state?.region; resourceInputs["requestTemplate"] = state?.requestTemplate; resourceInputs["responseTemplate"] = state?.responseTemplate; resourceInputs["runtime"] = state?.runtime; resourceInputs["syncConfig"] = state?.syncConfig; resourceInputs["type"] = state?.type; } else { const args = argsOrState; if (args?.apiId === undefined && !opts.urn) { throw new Error("Missing required property 'apiId'"); } if (args?.field === undefined && !opts.urn) { throw new Error("Missing required property 'field'"); } if (args?.type === undefined && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["apiId"] = args?.apiId; resourceInputs["cachingConfig"] = args?.cachingConfig; resourceInputs["code"] = args?.code; resourceInputs["dataSource"] = args?.dataSource; resourceInputs["field"] = args?.field; resourceInputs["kind"] = args?.kind; resourceInputs["maxBatchSize"] = args?.maxBatchSize; resourceInputs["pipelineConfig"] = args?.pipelineConfig; resourceInputs["region"] = args?.region; resourceInputs["requestTemplate"] = args?.requestTemplate; resourceInputs["responseTemplate"] = args?.responseTemplate; resourceInputs["runtime"] = args?.runtime; resourceInputs["syncConfig"] = args?.syncConfig; resourceInputs["type"] = args?.type; resourceInputs["arn"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Resolver.__pulumiType, name, resourceInputs, opts); } } exports.Resolver = Resolver; /** @internal */ Resolver.__pulumiType = 'aws:appsync/resolver:Resolver'; //# sourceMappingURL=resolver.js.map