UNPKG

@pulumi/command

Version:

[![Actions Status](https://github.com/pulumi/pulumi-command/workflows/master/badge.svg)](https://github.com/pulumi/pulumi-command/actions) [![Slack](http://www.pulumi.com/images/docs/badges/slack.svg)](https://slack.pulumi.com) [![NPM version](https://bad

141 lines 5.95 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! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Command = void 0; const pulumi = require("@pulumi/pulumi"); const inputs = require("../types/input"); const utilities = require("../utilities"); /** * A command to run on a remote host. The connection is established via ssh. * * ## Example Usage * * ### A Basic Example * This program connects to a server and runs the `hostname` command. The output is then available via the `stdout` property. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as command from "@pulumi/command"; * * const config = new pulumi.Config(); * const server = config.require("server"); * const userName = config.require("userName"); * const privateKey = config.require("privateKey"); * * const hostnameCmd = new command.remote.Command("hostnameCmd", { * create: "hostname", * connection: { * host: server, * user: userName, * privateKey: privateKey, * }, * }); * export const hostname = hostnameCmd.stdout; * ``` * * ### Triggers * This example defines several trigger values of various kinds. Changes to any of them will cause `cmd` to be re-run. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as command from "@pulumi/command"; * import * as random from "@pulumi/random"; * * const str = "foo"; * const fileAsset = new pulumi.asset.FileAsset("Pulumi.yaml"); * const rand = new random.RandomString("rand", {length: 5}); * const localFile = new command.local.Command("localFile", { * create: "touch foo.txt", * archivePaths: ["*.txt"], * }); * const cmd = new command.remote.Command("cmd", { * connection: { * host: "insert host here", * }, * create: "echo create > op.txt", * delete: "echo delete >> op.txt", * triggers: [ * str, * rand.result, * fileAsset, * localFile.archive, * ], * }); * * ``` */ class Command extends pulumi.CustomResource { /** * Get an existing Command 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 opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, opts) { return new Command(name, undefined, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Command. 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'] === Command.__pulumiType; } /** * Create a Command resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name, args, opts) { var _a; let resourceInputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.connection === undefined) && !opts.urn) { throw new Error("Missing required property 'connection'"); } resourceInputs["addPreviousOutputInEnv"] = (_a = (args ? args.addPreviousOutputInEnv : undefined)) !== null && _a !== void 0 ? _a : true; resourceInputs["connection"] = (args === null || args === void 0 ? void 0 : args.connection) ? pulumi.secret((args.connection ? pulumi.output(args.connection).apply(inputs.remote.connectionArgsProvideDefaults) : undefined)) : undefined; resourceInputs["create"] = args ? args.create : undefined; resourceInputs["delete"] = args ? args.delete : undefined; resourceInputs["environment"] = args ? args.environment : undefined; resourceInputs["logging"] = args ? args.logging : undefined; resourceInputs["stdin"] = args ? args.stdin : undefined; resourceInputs["triggers"] = args ? args.triggers : undefined; resourceInputs["update"] = args ? args.update : undefined; resourceInputs["stderr"] = undefined /*out*/; resourceInputs["stdout"] = undefined /*out*/; } else { resourceInputs["addPreviousOutputInEnv"] = undefined /*out*/; resourceInputs["connection"] = undefined /*out*/; resourceInputs["create"] = undefined /*out*/; resourceInputs["delete"] = undefined /*out*/; resourceInputs["environment"] = undefined /*out*/; resourceInputs["logging"] = undefined /*out*/; resourceInputs["stderr"] = undefined /*out*/; resourceInputs["stdin"] = undefined /*out*/; resourceInputs["stdout"] = undefined /*out*/; resourceInputs["triggers"] = undefined /*out*/; resourceInputs["update"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["connection"] }; opts = pulumi.mergeOptions(opts, secretOpts); const replaceOnChanges = { replaceOnChanges: ["triggers[*]"] }; opts = pulumi.mergeOptions(opts, replaceOnChanges); super(Command.__pulumiType, name, resourceInputs, opts); } } exports.Command = Command; /** @internal */ Command.__pulumiType = 'command:remote:Command'; //# sourceMappingURL=command.js.map