@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
171 lines • 6.06 kB
JavaScript
;
// *** 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.Function = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an AppSync Function.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* 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
* }
* `,
* });
* const exampleDataSource = new aws.appsync.DataSource("example", {
* apiId: example.id,
* name: "example",
* type: "HTTP",
* httpConfig: {
* endpoint: "http://example.com",
* },
* });
* const exampleFunction = new aws.appsync.Function("example", {
* 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
* `,
* });
* ```
*
* ### With Code
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const example = new aws.appsync.Function("example", {
* apiId: exampleAwsAppsyncGraphqlApi.id,
* dataSource: exampleAwsAppsyncDatasource.name,
* name: "example",
* code: std.file({
* input: "some-code-dir",
* }).then(invoke => invoke.result),
* runtime: {
* name: "APPSYNC_JS",
* runtimeVersion: "1.0.0",
* },
* });
* ```
*
* ## 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
* ```
*/
class Function extends pulumi.CustomResource {
/**
* Get an existing Function 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 Function(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Function. 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'] === Function.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["apiId"] = state?.apiId;
resourceInputs["arn"] = state?.arn;
resourceInputs["code"] = state?.code;
resourceInputs["dataSource"] = state?.dataSource;
resourceInputs["description"] = state?.description;
resourceInputs["functionId"] = state?.functionId;
resourceInputs["functionVersion"] = state?.functionVersion;
resourceInputs["maxBatchSize"] = state?.maxBatchSize;
resourceInputs["name"] = state?.name;
resourceInputs["region"] = state?.region;
resourceInputs["requestMappingTemplate"] = state?.requestMappingTemplate;
resourceInputs["responseMappingTemplate"] = state?.responseMappingTemplate;
resourceInputs["runtime"] = state?.runtime;
resourceInputs["syncConfig"] = state?.syncConfig;
}
else {
const args = argsOrState;
if (args?.apiId === undefined && !opts.urn) {
throw new Error("Missing required property 'apiId'");
}
if (args?.dataSource === undefined && !opts.urn) {
throw new Error("Missing required property 'dataSource'");
}
resourceInputs["apiId"] = args?.apiId;
resourceInputs["code"] = args?.code;
resourceInputs["dataSource"] = args?.dataSource;
resourceInputs["description"] = args?.description;
resourceInputs["functionVersion"] = args?.functionVersion;
resourceInputs["maxBatchSize"] = args?.maxBatchSize;
resourceInputs["name"] = args?.name;
resourceInputs["region"] = args?.region;
resourceInputs["requestMappingTemplate"] = args?.requestMappingTemplate;
resourceInputs["responseMappingTemplate"] = args?.responseMappingTemplate;
resourceInputs["runtime"] = args?.runtime;
resourceInputs["syncConfig"] = args?.syncConfig;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["functionId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Function.__pulumiType, name, resourceInputs, opts);
}
}
exports.Function = Function;
/** @internal */
Function.__pulumiType = 'aws:appsync/function:Function';
//# sourceMappingURL=function.js.map