@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
171 lines • 6.56 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, Object.assign(Object.assign({}, 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 ? state.apiId : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["code"] = state ? state.code : undefined;
resourceInputs["dataSource"] = state ? state.dataSource : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["functionId"] = state ? state.functionId : undefined;
resourceInputs["functionVersion"] = state ? state.functionVersion : undefined;
resourceInputs["maxBatchSize"] = state ? state.maxBatchSize : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["requestMappingTemplate"] = state ? state.requestMappingTemplate : undefined;
resourceInputs["responseMappingTemplate"] = state ? state.responseMappingTemplate : undefined;
resourceInputs["runtime"] = state ? state.runtime : undefined;
resourceInputs["syncConfig"] = state ? state.syncConfig : undefined;
}
else {
const args = argsOrState;
if ((!args || args.apiId === undefined) && !opts.urn) {
throw new Error("Missing required property 'apiId'");
}
if ((!args || args.dataSource === undefined) && !opts.urn) {
throw new Error("Missing required property 'dataSource'");
}
resourceInputs["apiId"] = args ? args.apiId : undefined;
resourceInputs["code"] = args ? args.code : undefined;
resourceInputs["dataSource"] = args ? args.dataSource : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["functionVersion"] = args ? args.functionVersion : undefined;
resourceInputs["maxBatchSize"] = args ? args.maxBatchSize : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["requestMappingTemplate"] = args ? args.requestMappingTemplate : undefined;
resourceInputs["responseMappingTemplate"] = args ? args.responseMappingTemplate : undefined;
resourceInputs["runtime"] = args ? args.runtime : undefined;
resourceInputs["syncConfig"] = args ? args.syncConfig : undefined;
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