UNPKG

@pulumiverse/scaleway

Version:

A Pulumi package for creating and managing Scaleway cloud resources.

246 lines 11.2 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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Function = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * The `scaleway.functions.Function` resource allows you to create and manage [Serverless Functions](https://www.scaleway.com/en/docs/serverless/functions/). * * Refer to the Serverless Functions [product documentation](https://www.scaleway.com/en/docs/serverless/functions/) and [API documentation](https://www.scaleway.com/en/developers/api/serverless-functions/) for more information. * * For more information on the limitations of Serverless Functions, refer to the [dedicated documentation](https://www.scaleway.com/en/docs/compute/functions/reference-content/functions-limitations/). * * ## Example Usage * * ### Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const main = new scaleway.functions.Namespace("main", { * name: "main-function-namespace", * description: "Main function namespace", * }); * const mainFunction = new scaleway.functions.Function("main", { * namespaceId: main.id, * runtime: "go124", * handler: "Handle", * privacy: "private", * }); * ``` * * ### With sources and deploy * * You can easily create a zip file containing your function (ex: `zip function.zip -r go.mod go.sum handler.go`) to deploy it with Terraform seamlessly. Refer to our [dedicated documentation](https://www.scaleway.com/en/docs/serverless/functions/how-to/package-function-dependencies-in-zip/) for more information on how to package a function into a zip file. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * import * as std from "@pulumi/std"; * * const main = new scaleway.functions.Namespace("main", { * name: "main-function-namespace", * description: "Main function namespace", * }); * const mainFunction = new scaleway.functions.Function("main", { * namespaceId: main.id, * description: "function with zip file", * tags: [ * "tag1", * "tag2", * ], * runtime: "go124", * handler: "Handle", * privacy: "private", * timeout: 10, * zipFile: "function.zip", * zipHash: std.filesha256({ * input: "function.zip", * }).result, * deploy: true, * }); * ``` * * ### Managing authentication of private functions with IAM * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * import * as std from "@pulumi/std"; * * // Project to be referenced in the IAM policy * const _default = scaleway.account.getProject({ * name: "default", * }); * // IAM resources * const funcAuth = new scaleway.iam.Application("func_auth", {name: "function-auth"}); * const accessPrivateFuncs = new scaleway.iam.Policy("access_private_funcs", { * applicationId: funcAuth.id, * rules: [{ * projectIds: [_default.then(_default => _default.id)], * permissionSetNames: ["FunctionsPrivateAccess"], * }], * }); * const apiKey = new scaleway.iam.ApiKey("api_key", {applicationId: funcAuth.id}); * // Function resources * const _private = new scaleway.functions.Namespace("private", {name: "private-function-namespace"}); * const privateFunction = new scaleway.functions.Function("private", { * namespaceId: _private.id, * runtime: "go124", * handler: "Handle", * privacy: "private", * zipFile: "function.zip", * zipHash: std.filesha256({ * input: "function.zip", * }).result, * deploy: true, * }); * export const secretKey = apiKey.secretKey; * export const functionEndpoint = privateFunction.domainName; * ``` * * Then you can access your private function using the API key: * * Keep in mind that you should revoke your legacy JWT tokens to ensure maximum security. * * ## Import * * Functions can be imported using, `{region}/{id}`, as shown below: * * ```sh * $ pulumi import scaleway:index/function:Function main fr-par/11111111-1111-1111-1111-111111111111 * ``` * * @deprecated scaleway.index/function.Function has been deprecated in favor of scaleway.functions/function.Function */ 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) { pulumi.log.warn("Function is deprecated: scaleway.index/function.Function has been deprecated in favor of scaleway.functions/function.Function"); return new Function(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'scaleway:index/function:Function'; /** * 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; } /** @deprecated scaleway.index/function.Function has been deprecated in favor of scaleway.functions/function.Function */ constructor(name, argsOrState, opts) { pulumi.log.warn("Function is deprecated: scaleway.index/function.Function has been deprecated in favor of scaleway.functions/function.Function"); let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["cpuLimit"] = state?.cpuLimit; resourceInputs["deploy"] = state?.deploy; resourceInputs["description"] = state?.description; resourceInputs["domainName"] = state?.domainName; resourceInputs["environmentVariables"] = state?.environmentVariables; resourceInputs["handler"] = state?.handler; resourceInputs["httpOption"] = state?.httpOption; resourceInputs["maxScale"] = state?.maxScale; resourceInputs["memoryLimit"] = state?.memoryLimit; resourceInputs["minScale"] = state?.minScale; resourceInputs["name"] = state?.name; resourceInputs["namespaceId"] = state?.namespaceId; resourceInputs["organizationId"] = state?.organizationId; resourceInputs["privacy"] = state?.privacy; resourceInputs["privateNetworkId"] = state?.privateNetworkId; resourceInputs["projectId"] = state?.projectId; resourceInputs["region"] = state?.region; resourceInputs["runtime"] = state?.runtime; resourceInputs["sandbox"] = state?.sandbox; resourceInputs["secretEnvironmentVariables"] = state?.secretEnvironmentVariables; resourceInputs["tags"] = state?.tags; resourceInputs["timeout"] = state?.timeout; resourceInputs["zipFile"] = state?.zipFile; resourceInputs["zipHash"] = state?.zipHash; } else { const args = argsOrState; if (args?.handler === undefined && !opts.urn) { throw new Error("Missing required property 'handler'"); } if (args?.namespaceId === undefined && !opts.urn) { throw new Error("Missing required property 'namespaceId'"); } if (args?.privacy === undefined && !opts.urn) { throw new Error("Missing required property 'privacy'"); } if (args?.runtime === undefined && !opts.urn) { throw new Error("Missing required property 'runtime'"); } resourceInputs["deploy"] = args?.deploy; resourceInputs["description"] = args?.description; resourceInputs["environmentVariables"] = args?.environmentVariables; resourceInputs["handler"] = args?.handler; resourceInputs["httpOption"] = args?.httpOption; resourceInputs["maxScale"] = args?.maxScale; resourceInputs["memoryLimit"] = args?.memoryLimit; resourceInputs["minScale"] = args?.minScale; resourceInputs["name"] = args?.name; resourceInputs["namespaceId"] = args?.namespaceId; resourceInputs["privacy"] = args?.privacy; resourceInputs["privateNetworkId"] = args?.privateNetworkId; resourceInputs["projectId"] = args?.projectId; resourceInputs["region"] = args?.region; resourceInputs["runtime"] = args?.runtime; resourceInputs["sandbox"] = args?.sandbox; resourceInputs["secretEnvironmentVariables"] = args?.secretEnvironmentVariables ? pulumi.secret(args.secretEnvironmentVariables) : undefined; resourceInputs["tags"] = args?.tags; resourceInputs["timeout"] = args?.timeout; resourceInputs["zipFile"] = args?.zipFile; resourceInputs["zipHash"] = args?.zipHash; resourceInputs["cpuLimit"] = undefined /*out*/; resourceInputs["domainName"] = undefined /*out*/; resourceInputs["organizationId"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["secretEnvironmentVariables"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Function.__pulumiType, name, resourceInputs, opts); } } exports.Function = Function; //# sourceMappingURL=function.js.map