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

134 lines 5.77 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.CopyToRemote = void 0; const pulumi = require("@pulumi/pulumi"); const inputs = require("../types/input"); const utilities = require("../utilities"); /** * Copy an Asset or Archive to a remote host. * * ## Example usage * * This example copies a local directory to a remote host via SSH. For brevity, the remote server is assumed to exist, but it could also be provisioned in the same Pulumi program. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import { remote, types } from "@pulumi/command"; * import * as fs from "fs"; * import * as os from "os"; * import * as path from "path"; * * export = async () => { * const config = new pulumi.Config(); * * // Get the private key to connect to the server. If a key is * // provided, use it, otherwise default to the standard id_rsa SSH key. * const privateKeyBase64 = config.get("privateKeyBase64"); * const privateKey = privateKeyBase64 ? * Buffer.from(privateKeyBase64, 'base64').toString('ascii') : * fs.readFileSync(path.join(os.homedir(), ".ssh", "id_rsa")).toString("utf8"); * * const serverPublicIp = config.require("serverPublicIp"); * const userName = config.require("userName"); * * // The configuration of our SSH connection to the instance. * const connection: types.input.remote.ConnectionArgs = { * host: serverPublicIp, * user: userName, * privateKey: privateKey, * }; * * // Set up source and target of the remote copy. * const from = config.require("payload")!; * const archive = new pulumi.asset.FileArchive(from); * const to = config.require("destDir")!; * * // Copy the files to the remote. * const copy = new remote.CopyToRemote("copy", { * connection, * source: archive, * remotePath: to, * }); * * // Verify that the expected files were copied to the remote. * // We want to run this after each copy, i.e., when something changed, * // so we use the asset to be copied as a trigger. * const find = new remote.Command("ls", { * connection, * create: `find ${to}/${from} | sort`, * triggers: [archive], * }, { dependsOn: copy }); * * return { * remoteContents: find.stdout * } * } * ``` */ class CopyToRemote extends pulumi.CustomResource { /** * Get an existing CopyToRemote 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 CopyToRemote(name, undefined, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of CopyToRemote. 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'] === CopyToRemote.__pulumiType; } /** * Create a CopyToRemote 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) { let resourceInputs = {}; opts = opts || {}; if (!opts.id) { if ((!args || args.connection === undefined) && !opts.urn) { throw new Error("Missing required property 'connection'"); } if ((!args || args.remotePath === undefined) && !opts.urn) { throw new Error("Missing required property 'remotePath'"); } if ((!args || args.source === undefined) && !opts.urn) { throw new Error("Missing required property 'source'"); } 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["remotePath"] = args ? args.remotePath : undefined; resourceInputs["source"] = args ? args.source : undefined; resourceInputs["triggers"] = args ? args.triggers : undefined; } else { resourceInputs["connection"] = undefined /*out*/; resourceInputs["remotePath"] = undefined /*out*/; resourceInputs["source"] = undefined /*out*/; resourceInputs["triggers"] = 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(CopyToRemote.__pulumiType, name, resourceInputs, opts); } } exports.CopyToRemote = CopyToRemote; /** @internal */ CopyToRemote.__pulumiType = 'command:remote:CopyToRemote'; //# sourceMappingURL=copyToRemote.js.map