UNPKG

@pulumi/aws

Version:

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

205 lines • 7.56 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 { * \x09putPost(id: ID!, title: String!): Post * } * * type Post { * \x09id: ID! * \x09title: String! * } * * type Query { * \x09singlePost(id: ID!): Post * } * * schema { * \x09query: Query * \x09mutation: 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, Object.assign(Object.assign({}, 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 ? state.apiId : undefined; resourceInputs["arn"] = state ? state.arn : undefined; resourceInputs["cachingConfig"] = state ? state.cachingConfig : undefined; resourceInputs["code"] = state ? state.code : undefined; resourceInputs["dataSource"] = state ? state.dataSource : undefined; resourceInputs["field"] = state ? state.field : undefined; resourceInputs["kind"] = state ? state.kind : undefined; resourceInputs["maxBatchSize"] = state ? state.maxBatchSize : undefined; resourceInputs["pipelineConfig"] = state ? state.pipelineConfig : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["requestTemplate"] = state ? state.requestTemplate : undefined; resourceInputs["responseTemplate"] = state ? state.responseTemplate : undefined; resourceInputs["runtime"] = state ? state.runtime : undefined; resourceInputs["syncConfig"] = state ? state.syncConfig : undefined; resourceInputs["type"] = state ? state.type : undefined; } else { const args = argsOrState; if ((!args || args.apiId === undefined) && !opts.urn) { throw new Error("Missing required property 'apiId'"); } if ((!args || args.field === undefined) && !opts.urn) { throw new Error("Missing required property 'field'"); } if ((!args || args.type === undefined) && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["apiId"] = args ? args.apiId : undefined; resourceInputs["cachingConfig"] = args ? args.cachingConfig : undefined; resourceInputs["code"] = args ? args.code : undefined; resourceInputs["dataSource"] = args ? args.dataSource : undefined; resourceInputs["field"] = args ? args.field : undefined; resourceInputs["kind"] = args ? args.kind : undefined; resourceInputs["maxBatchSize"] = args ? args.maxBatchSize : undefined; resourceInputs["pipelineConfig"] = args ? args.pipelineConfig : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["requestTemplate"] = args ? args.requestTemplate : undefined; resourceInputs["responseTemplate"] = args ? args.responseTemplate : undefined; resourceInputs["runtime"] = args ? args.runtime : undefined; resourceInputs["syncConfig"] = args ? args.syncConfig : undefined; resourceInputs["type"] = args ? args.type : undefined; 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