UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

285 lines 15.6 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** 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"); /** * Manages the function resource within HuaweiCloud. * * > Since version `1.73.1`, the requests of the function resource will send these parameters:<br> * `enableDynamicMemory`<br> * `isStatefulFunction`<br> * `networkController`<br> * Since version `1.74.0`, the requests of the function resource will send these parameters:<br> * `enableAuthInHeader`<br> * `enableClassIsolation`<br> * For the regions that do not support this parameter, please use the lower version to deploy this resource. * * ## Example Usage * ### With text code * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const functionName = config.requireObject("functionName"); * const agencyName = config.requireObject("agencyName"); * const test = new huaweicloud.functiongraph.Function("test", { * app: "default", * agency: agencyName, * handler: "test.handler", * memorySize: 128, * timeout: 3, * runtime: "Python2.7", * codeType: "inline", * funcCode: `# -*- coding:utf-8 -*- * import json * def handler (event, context): * return { * "statusCode": 200, * "isBase64Encoded": False, * "body": json.dumps(event), * "headers": { * "Content-Type": "application/json" * } * } * `, * }); * ``` * ### Create function using SWR image * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const functionName = config.requireObject("functionName"); * const agencyName = config.requireObject("agencyName"); * const imageUrl = config.requireObject("imageUrl"); * const bySwrImage = new huaweicloud.functiongraph.Function("bySwrImage", { * agency: agencyName, * handler: "-", * app: "default", * runtime: "Custom Image", * codeType: "Custom-Image-Swr", * memorySize: 128, * timeout: 3, * customImage: { * url: imageUrl, * }, * }); * ``` * ### Create function with Java runtime and corresponding configuration * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const functionName = config.requireObject("functionName"); * const agencyName = config.requireObject("agencyName"); * const test = new huaweicloud.functiongraph.Function("test", { * memorySize: 128, * runtime: "Java11", * timeout: 15, * app: "default", * handler: "com.huawei.demo.TriggerTests.apigTest", * codeType: "zip", * codeFilename: "java-demo.zip", * agency: agencyName, * enableClassIsolation: true, * ephemeralStorage: 512, * heartbeatHandler: "com.huawei.demo.TriggerTests.heartBeat", * restoreHookHandler: "com.huawei.demo.TriggerTests.restoreHook", * restoreHookTimeout: 10, * }); * ``` * * ## Import * * Functions can be imported using the `id`, e.g. bash * * ```sh * $ pulumi import huaweicloud:FunctionGraph/function:Function test <id> * ``` * * Note that the imported state may not be identical to your resource definition, due to the attribute missing from the API response. The missing attributes are`func_code`, `encrypted_user_data`, `tags`. It is generally recommended running `terraform plan` after importing a function. You can then decide if changes should be applied to the function, or the resource definition should be updated to align with the function. Also you can ignore changes as below. hcl resource "huaweicloud_fgs_function" "test" { * * ... * * lifecycle { * * ignore_changes = [ * * app, func_code, tags, * * ] * * } } */ 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["agency"] = state ? state.agency : undefined; resourceInputs["app"] = state ? state.app : undefined; resourceInputs["appAgency"] = state ? state.appAgency : undefined; resourceInputs["codeFilename"] = state ? state.codeFilename : undefined; resourceInputs["codeType"] = state ? state.codeType : undefined; resourceInputs["codeUrl"] = state ? state.codeUrl : undefined; resourceInputs["concurrencyNum"] = state ? state.concurrencyNum : undefined; resourceInputs["customImage"] = state ? state.customImage : undefined; resourceInputs["dependLists"] = state ? state.dependLists : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["dnsList"] = state ? state.dnsList : undefined; resourceInputs["enableAuthInHeader"] = state ? state.enableAuthInHeader : undefined; resourceInputs["enableClassIsolation"] = state ? state.enableClassIsolation : undefined; resourceInputs["enableDynamicMemory"] = state ? state.enableDynamicMemory : undefined; resourceInputs["encryptedUserData"] = state ? state.encryptedUserData : undefined; resourceInputs["enterpriseProjectId"] = state ? state.enterpriseProjectId : undefined; resourceInputs["ephemeralStorage"] = state ? state.ephemeralStorage : undefined; resourceInputs["funcCode"] = state ? state.funcCode : undefined; resourceInputs["funcMounts"] = state ? state.funcMounts : undefined; resourceInputs["functiongraphVersion"] = state ? state.functiongraphVersion : undefined; resourceInputs["gpuMemory"] = state ? state.gpuMemory : undefined; resourceInputs["gpuType"] = state ? state.gpuType : undefined; resourceInputs["handler"] = state ? state.handler : undefined; resourceInputs["heartbeatHandler"] = state ? state.heartbeatHandler : undefined; resourceInputs["initializerHandler"] = state ? state.initializerHandler : undefined; resourceInputs["initializerTimeout"] = state ? state.initializerTimeout : undefined; resourceInputs["isStatefulFunction"] = state ? state.isStatefulFunction : undefined; resourceInputs["logGroupId"] = state ? state.logGroupId : undefined; resourceInputs["logGroupName"] = state ? state.logGroupName : undefined; resourceInputs["logStreamId"] = state ? state.logStreamId : undefined; resourceInputs["logStreamName"] = state ? state.logStreamName : undefined; resourceInputs["ltsCustomTag"] = state ? state.ltsCustomTag : undefined; resourceInputs["ltsCustomTagOrigin"] = state ? state.ltsCustomTagOrigin : undefined; resourceInputs["maxInstanceNum"] = state ? state.maxInstanceNum : undefined; resourceInputs["memorySize"] = state ? state.memorySize : undefined; resourceInputs["mountUserGroupId"] = state ? state.mountUserGroupId : undefined; resourceInputs["mountUserId"] = state ? state.mountUserId : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["networkController"] = state ? state.networkController : undefined; resourceInputs["networkId"] = state ? state.networkId : undefined; resourceInputs["package"] = state ? state.package : undefined; resourceInputs["peeringCidr"] = state ? state.peeringCidr : undefined; resourceInputs["preStopHandler"] = state ? state.preStopHandler : undefined; resourceInputs["preStopTimeout"] = state ? state.preStopTimeout : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["reservedInstances"] = state ? state.reservedInstances : undefined; resourceInputs["restoreHookHandler"] = state ? state.restoreHookHandler : undefined; resourceInputs["restoreHookTimeout"] = state ? state.restoreHookTimeout : undefined; resourceInputs["runtime"] = state ? state.runtime : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["timeout"] = state ? state.timeout : undefined; resourceInputs["urn"] = state ? state.urn : undefined; resourceInputs["userData"] = state ? state.userData : undefined; resourceInputs["version"] = state ? state.version : undefined; resourceInputs["versions"] = state ? state.versions : undefined; resourceInputs["vpcId"] = state ? state.vpcId : undefined; resourceInputs["xrole"] = state ? state.xrole : undefined; } else { const args = argsOrState; if ((!args || args.memorySize === undefined) && !opts.urn) { throw new Error("Missing required property 'memorySize'"); } if ((!args || args.runtime === undefined) && !opts.urn) { throw new Error("Missing required property 'runtime'"); } if ((!args || args.timeout === undefined) && !opts.urn) { throw new Error("Missing required property 'timeout'"); } resourceInputs["agency"] = args ? args.agency : undefined; resourceInputs["app"] = args ? args.app : undefined; resourceInputs["appAgency"] = args ? args.appAgency : undefined; resourceInputs["codeFilename"] = args ? args.codeFilename : undefined; resourceInputs["codeType"] = args ? args.codeType : undefined; resourceInputs["codeUrl"] = args ? args.codeUrl : undefined; resourceInputs["concurrencyNum"] = args ? args.concurrencyNum : undefined; resourceInputs["customImage"] = args ? args.customImage : undefined; resourceInputs["dependLists"] = args ? args.dependLists : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["dnsList"] = args ? args.dnsList : undefined; resourceInputs["enableAuthInHeader"] = args ? args.enableAuthInHeader : undefined; resourceInputs["enableClassIsolation"] = args ? args.enableClassIsolation : undefined; resourceInputs["enableDynamicMemory"] = args ? args.enableDynamicMemory : undefined; resourceInputs["encryptedUserData"] = args ? args.encryptedUserData : undefined; resourceInputs["enterpriseProjectId"] = args ? args.enterpriseProjectId : undefined; resourceInputs["ephemeralStorage"] = args ? args.ephemeralStorage : undefined; resourceInputs["funcCode"] = args ? args.funcCode : undefined; resourceInputs["funcMounts"] = args ? args.funcMounts : undefined; resourceInputs["functiongraphVersion"] = args ? args.functiongraphVersion : undefined; resourceInputs["gpuMemory"] = args ? args.gpuMemory : undefined; resourceInputs["gpuType"] = args ? args.gpuType : undefined; resourceInputs["handler"] = args ? args.handler : undefined; resourceInputs["heartbeatHandler"] = args ? args.heartbeatHandler : undefined; resourceInputs["initializerHandler"] = args ? args.initializerHandler : undefined; resourceInputs["initializerTimeout"] = args ? args.initializerTimeout : undefined; resourceInputs["isStatefulFunction"] = args ? args.isStatefulFunction : undefined; resourceInputs["logGroupId"] = args ? args.logGroupId : undefined; resourceInputs["logGroupName"] = args ? args.logGroupName : undefined; resourceInputs["logStreamId"] = args ? args.logStreamId : undefined; resourceInputs["logStreamName"] = args ? args.logStreamName : undefined; resourceInputs["ltsCustomTag"] = args ? args.ltsCustomTag : undefined; resourceInputs["maxInstanceNum"] = args ? args.maxInstanceNum : undefined; resourceInputs["memorySize"] = args ? args.memorySize : undefined; resourceInputs["mountUserGroupId"] = args ? args.mountUserGroupId : undefined; resourceInputs["mountUserId"] = args ? args.mountUserId : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["networkController"] = args ? args.networkController : undefined; resourceInputs["networkId"] = args ? args.networkId : undefined; resourceInputs["package"] = args ? args.package : undefined; resourceInputs["peeringCidr"] = args ? args.peeringCidr : undefined; resourceInputs["preStopHandler"] = args ? args.preStopHandler : undefined; resourceInputs["preStopTimeout"] = args ? args.preStopTimeout : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["reservedInstances"] = args ? args.reservedInstances : undefined; resourceInputs["restoreHookHandler"] = args ? args.restoreHookHandler : undefined; resourceInputs["restoreHookTimeout"] = args ? args.restoreHookTimeout : undefined; resourceInputs["runtime"] = args ? args.runtime : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["timeout"] = args ? args.timeout : undefined; resourceInputs["userData"] = args ? args.userData : undefined; resourceInputs["versions"] = args ? args.versions : undefined; resourceInputs["vpcId"] = args ? args.vpcId : undefined; resourceInputs["xrole"] = args ? args.xrole : undefined; resourceInputs["ltsCustomTagOrigin"] = undefined /*out*/; resourceInputs["urn"] = undefined /*out*/; resourceInputs["version"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Function.__pulumiType, name, resourceInputs, opts); } } exports.Function = Function; /** @internal */ Function.__pulumiType = 'huaweicloud:FunctionGraph/function:Function'; //# sourceMappingURL=function.js.map