UNPKG

@pulumiverse/scaleway

Version:

A Pulumi package for creating and managing Scaleway cloud resources.

145 lines 5.98 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.UserData = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Creates and manages Scaleway compute Instance User Data values. * * User data is a key value store API you can use to provide data from and to your server without authentication. It is the mechanism by which a user can pass information contained in a local file to an Instance at launch time. * * The typical use case is to pass something like a shell script or a configuration file as user data. * * For more information about [userData](https://www.scaleway.com/en/developers/api/instance/#path-user-data-list-user-data) check [our documentation guide](https://www.scaleway.com/en/docs/compute/instances/how-to/use-boot-modes/#how-to-use-cloud-init). * * About cloud-init documentation please check [the official documentation](https://cloudinit.readthedocs.io/en/latest/). * * ## Example Usage * * ### Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const config = new pulumi.Config(); * const userData = config.getObject<Record<string, any>>("userData") || { * "cloud-init": `#cloud-config * apt-update: true * apt-upgrade: true * `, * foo: "bar", * }; * const mainServer = new scaleway.instance.Server("main", { * image: "ubuntu_focal", * type: "DEV1-S", * }); * // User data with a single value * const main = new scaleway.instance.UserData("main", { * serverId: mainServer.id, * key: "foo", * value: "bar", * }); * // User Data with many keys. * const data: scaleway.instance.UserData[] = []; * for (const range of Object.entries(userData).sort().map(([k, v]) => ({key: k, value: v}))) { * data.push(new scaleway.instance.UserData(`data-${range.key}`, { * serverId: mainServer.id, * key: range.key, * value: range.value, * })); * } * ``` * * ## Import * * User data can be imported using the `{zone}/{key}/{server_id}`, e.g. * * ```sh * $ pulumi import scaleway:instance/userData:UserData main fr-par-1/cloud-init/11111111-1111-1111-1111-111111111111 * ``` */ class UserData extends pulumi.CustomResource { /** * Get an existing UserData 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 UserData(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'scaleway:instance/userData:UserData'; /** * Returns true if the given object is an instance of UserData. 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'] === UserData.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["key"] = state?.key; resourceInputs["serverId"] = state?.serverId; resourceInputs["value"] = state?.value; resourceInputs["zone"] = state?.zone; } else { const args = argsOrState; if (args?.key === undefined && !opts.urn) { throw new Error("Missing required property 'key'"); } if (args?.serverId === undefined && !opts.urn) { throw new Error("Missing required property 'serverId'"); } if (args?.value === undefined && !opts.urn) { throw new Error("Missing required property 'value'"); } resourceInputs["key"] = args?.key; resourceInputs["serverId"] = args?.serverId; resourceInputs["value"] = args?.value; resourceInputs["zone"] = args?.zone; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "scaleway:index/instanceUserData:InstanceUserData" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(UserData.__pulumiType, name, resourceInputs, opts); } } exports.UserData = UserData; //# sourceMappingURL=userData.js.map