@pulumi/linode
Version:
A Pulumi package for creating and managing linode cloud resources.
133 lines • 6.48 kB
JavaScript
// *** 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.StackScript = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Provides a Linode StackScript resource. This can be used to create, modify, and delete Linode StackScripts. StackScripts are private or public managed scripts which run within an instance during startup. StackScripts can include variables whose values are specified when the Instance is created.
*
* For more information, see [Automate Deployment with StackScripts](https://www.linode.com/docs/platform/stackscripts/) and the [Linode APIv4 docs](https://techdocs.akamai.com/linode-api/reference/post-add-stack-script).
*
* ## Example Usage
*
* The following example shows how one might use this resource to configure a StackScript attached to a Linode Instance. As shown below, StackScripts must begin with a shebang (`#!`). The `<UDF ...>` element provided in the Bash comment block defines a variable whose value is provided when creating the Instance (or disk) using the `stackscriptData` field.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as linode from "@pulumi/linode";
*
* const foo = new linode.StackScript("foo", {
* label: "foo",
* description: "Installs a Package",
* script: `#!/bin/bash
* # <UDF name="package" label="System Package to Install" example="nginx" default="">
* apt-get -q update && apt-get -q -y install PACKAGE
* `,
* images: [
* "linode/ubuntu22.04",
* "linode/ubuntu20.04",
* ],
* revNote: "initial version",
* });
* const fooInstance = new linode.Instance("foo", {
* image: "linode/ubuntu22.04",
* label: "foo",
* region: "us-east",
* type: "g6-nanode-1",
* authorizedKeys: ["..."],
* rootPass: "...",
* stackscriptId: foo.id,
* stackscriptData: {
* "package": "nginx",
* },
* });
* ```
*
* ## Import
*
* Linodes StackScripts can be imported using the Linode StackScript `id`, e.g.
*
* ```sh
* $ pulumi import linode:index/stackScript:StackScript mystackscript 1234567
* ```
*/
class StackScript extends pulumi.CustomResource {
/**
* Get an existing StackScript 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 StackScript(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of StackScript. 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'] === StackScript.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["created"] = state ? state.created : undefined;
resourceInputs["deploymentsActive"] = state ? state.deploymentsActive : undefined;
resourceInputs["deploymentsTotal"] = state ? state.deploymentsTotal : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["images"] = state ? state.images : undefined;
resourceInputs["isPublic"] = state ? state.isPublic : undefined;
resourceInputs["label"] = state ? state.label : undefined;
resourceInputs["revNote"] = state ? state.revNote : undefined;
resourceInputs["script"] = state ? state.script : undefined;
resourceInputs["updated"] = state ? state.updated : undefined;
resourceInputs["userDefinedFields"] = state ? state.userDefinedFields : undefined;
resourceInputs["userGravatarId"] = state ? state.userGravatarId : undefined;
resourceInputs["username"] = state ? state.username : undefined;
}
else {
const args = argsOrState;
if ((!args || args.description === undefined) && !opts.urn) {
throw new Error("Missing required property 'description'");
}
if ((!args || args.images === undefined) && !opts.urn) {
throw new Error("Missing required property 'images'");
}
if ((!args || args.label === undefined) && !opts.urn) {
throw new Error("Missing required property 'label'");
}
if ((!args || args.script === undefined) && !opts.urn) {
throw new Error("Missing required property 'script'");
}
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["images"] = args ? args.images : undefined;
resourceInputs["isPublic"] = args ? args.isPublic : undefined;
resourceInputs["label"] = args ? args.label : undefined;
resourceInputs["revNote"] = args ? args.revNote : undefined;
resourceInputs["script"] = args ? args.script : undefined;
resourceInputs["created"] = undefined /*out*/;
resourceInputs["deploymentsActive"] = undefined /*out*/;
resourceInputs["deploymentsTotal"] = undefined /*out*/;
resourceInputs["updated"] = undefined /*out*/;
resourceInputs["userDefinedFields"] = undefined /*out*/;
resourceInputs["userGravatarId"] = undefined /*out*/;
resourceInputs["username"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(StackScript.__pulumiType, name, resourceInputs, opts);
}
}
exports.StackScript = StackScript;
/** @internal */
StackScript.__pulumiType = 'linode:index/stackScript:StackScript';
//# sourceMappingURL=stackScript.js.map
;