@pulumi/command 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -6
- package/local/command.d.ts +44 -1
- package/local/command.js +44 -1
- package/local/command.js.map +1 -1
- package/package.json +3 -3
- package/package.json.dev +2 -2
- package/remote/command.d.ts +24 -1
- package/remote/command.js +24 -1
- package/remote/command.js.map +1 -1
- package/remote/copyToRemote.d.ts +58 -0
- package/remote/copyToRemote.js +58 -0
- package/remote/copyToRemote.js.map +1 -1
package/README.md
CHANGED
|
@@ -265,21 +265,46 @@ curl \
|
|
|
265
265
|
|
|
266
266
|
There are cases where it's important to run some cleanup operation before destroying a resource such as when destroying the resource does not properly handle orderly cleanup. For example, destroying an EKS Cluster will not ensure that all Kubernetes object finalizers are run, which may lead to leaking external resources managed by those Kubernetes resources. This example shows how we can use a `delete`-only `Command` to ensure some cleanup is run within a cluster before destroying it.
|
|
267
267
|
|
|
268
|
+
```yaml
|
|
269
|
+
resources:
|
|
270
|
+
cluster:
|
|
271
|
+
type: eks:Cluster
|
|
272
|
+
|
|
273
|
+
cleanupKubernetesNamespaces:
|
|
274
|
+
# We could also use `RemoteCommand` to run this from
|
|
275
|
+
# within a node in the cluster.
|
|
276
|
+
type: command:local:Command
|
|
277
|
+
properties:
|
|
278
|
+
# This will run before the cluster is destroyed.
|
|
279
|
+
# Everything else will need to depend on this resource
|
|
280
|
+
# to ensure this cleanup doesn't happen too early.
|
|
281
|
+
delete: |
|
|
282
|
+
kubectl --kubeconfig <(echo "$KUBECONFIG_DATA") delete namespace nginx
|
|
283
|
+
# Process substitution "<()" doesn't work in the default interpreter sh.
|
|
284
|
+
interpreter: ["/bin/bash", "-c"]
|
|
285
|
+
environment:
|
|
286
|
+
KUBECONFIG_DATA: "${cluster.kubeconfigJson}"
|
|
287
|
+
```
|
|
288
|
+
|
|
268
289
|
```ts
|
|
269
|
-
import
|
|
290
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
291
|
+
import * as command from "@pulumi/command";
|
|
270
292
|
import * as eks from "@pulumi/eks";
|
|
271
|
-
import * as random from "@pulumi/random";
|
|
272
|
-
import { interpolate } from "@pulumi/pulumi";
|
|
273
293
|
|
|
274
294
|
const cluster = new eks.Cluster("cluster", {});
|
|
275
295
|
|
|
276
296
|
// We could also use `RemoteCommand` to run this from within a node in the cluster
|
|
277
|
-
const cleanupKubernetesNamespaces = new local.Command("cleanupKubernetesNamespaces", {
|
|
297
|
+
const cleanupKubernetesNamespaces = new command.local.Command("cleanupKubernetesNamespaces", {
|
|
278
298
|
// This will run before the cluster is destroyed. Everything else will need to
|
|
279
299
|
// depend on this resource to ensure this cleanup doesn't happen too early.
|
|
280
|
-
delete: "kubectl delete
|
|
300
|
+
"delete": "kubectl --kubeconfig <(echo \"$KUBECONFIG_DATA\") delete namespace nginx\n",
|
|
301
|
+
// Process substitution "<()" doesn't work in the default interpreter sh.
|
|
302
|
+
interpreter: [
|
|
303
|
+
"/bin/bash",
|
|
304
|
+
"-c",
|
|
305
|
+
],
|
|
281
306
|
environment: {
|
|
282
|
-
|
|
307
|
+
KUBECONFIG_DATA: cluster.kubeconfigJson,
|
|
283
308
|
},
|
|
284
309
|
});
|
|
285
310
|
```
|
package/local/command.d.ts
CHANGED
|
@@ -6,7 +6,50 @@ import * as enums from "../types/enums";
|
|
|
6
6
|
* This command can be inserted into the life cycles of other resources using the `dependsOn` or `parent` resource options. A command is considered to have failed when it finished with a non-zero exit code. This will fail the CRUD step of the `Command` resource.
|
|
7
7
|
*
|
|
8
8
|
* ## Example Usage
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
|
+
* ### Basic Example
|
|
11
|
+
*
|
|
12
|
+
* This example shows the simplest use case, simply running a command on `create` in the Pulumi lifecycle.
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { local } from "@pulumi/command";
|
|
16
|
+
*
|
|
17
|
+
* const random = new local.Command("random", {
|
|
18
|
+
* create: "openssl rand -hex 16",
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* export const output = random.stdout;
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ### Invoking a Lambda during Pulumi Deployment
|
|
25
|
+
*
|
|
26
|
+
* This example show using a local command to invoke an AWS Lambda once it's deployed. The Lambda invocation could also depend on other resources.
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* import * as aws from "@pulumi/aws";
|
|
30
|
+
* import { local } from "@pulumi/command";
|
|
31
|
+
* import { getStack } from "@pulumi/pulumi";
|
|
32
|
+
*
|
|
33
|
+
* const f = new aws.lambda.CallbackFunction("f", {
|
|
34
|
+
* publish: true,
|
|
35
|
+
* callback: async (ev: any) => {
|
|
36
|
+
* return `Stack ${ev.stackName} is deployed!`;
|
|
37
|
+
* }
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* const invoke = new local.Command("execf", {
|
|
41
|
+
* create: `aws lambda invoke --function-name "$FN" --payload '{"stackName": "${getStack()}"}' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d '"' && rm out.txt`,
|
|
42
|
+
* environment: {
|
|
43
|
+
* FN: f.qualifiedArn,
|
|
44
|
+
* AWS_REGION: aws.config.region!,
|
|
45
|
+
* AWS_PAGER: "",
|
|
46
|
+
* },
|
|
47
|
+
* }, { dependsOn: f })
|
|
48
|
+
*
|
|
49
|
+
* export const output = invoke.stdout;
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* ### Using Triggers
|
|
10
53
|
*
|
|
11
54
|
* This example defines several trigger values of various kinds. Changes to any of them will cause `cmd` to be re-run.
|
|
12
55
|
*
|
package/local/command.js
CHANGED
|
@@ -11,7 +11,50 @@ const utilities = require("../utilities");
|
|
|
11
11
|
* This command can be inserted into the life cycles of other resources using the `dependsOn` or `parent` resource options. A command is considered to have failed when it finished with a non-zero exit code. This will fail the CRUD step of the `Command` resource.
|
|
12
12
|
*
|
|
13
13
|
* ## Example Usage
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* ### Basic Example
|
|
16
|
+
*
|
|
17
|
+
* This example shows the simplest use case, simply running a command on `create` in the Pulumi lifecycle.
|
|
18
|
+
*
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { local } from "@pulumi/command";
|
|
21
|
+
*
|
|
22
|
+
* const random = new local.Command("random", {
|
|
23
|
+
* create: "openssl rand -hex 16",
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* export const output = random.stdout;
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* ### Invoking a Lambda during Pulumi Deployment
|
|
30
|
+
*
|
|
31
|
+
* This example show using a local command to invoke an AWS Lambda once it's deployed. The Lambda invocation could also depend on other resources.
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import * as aws from "@pulumi/aws";
|
|
35
|
+
* import { local } from "@pulumi/command";
|
|
36
|
+
* import { getStack } from "@pulumi/pulumi";
|
|
37
|
+
*
|
|
38
|
+
* const f = new aws.lambda.CallbackFunction("f", {
|
|
39
|
+
* publish: true,
|
|
40
|
+
* callback: async (ev: any) => {
|
|
41
|
+
* return `Stack ${ev.stackName} is deployed!`;
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const invoke = new local.Command("execf", {
|
|
46
|
+
* create: `aws lambda invoke --function-name "$FN" --payload '{"stackName": "${getStack()}"}' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d '"' && rm out.txt`,
|
|
47
|
+
* environment: {
|
|
48
|
+
* FN: f.qualifiedArn,
|
|
49
|
+
* AWS_REGION: aws.config.region!,
|
|
50
|
+
* AWS_PAGER: "",
|
|
51
|
+
* },
|
|
52
|
+
* }, { dependsOn: f })
|
|
53
|
+
*
|
|
54
|
+
* export const output = invoke.stdout;
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* ### Using Triggers
|
|
15
58
|
*
|
|
16
59
|
* This example defines several trigger values of various kinds. Changes to any of them will cause `cmd` to be re-run.
|
|
17
60
|
*
|
package/local/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../local/command.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,iFAAiF;;;AAEjF,yCAAyC;AAIzC,0CAA0C;AAE1C
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../local/command.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,iFAAiF;;;AAEjF,yCAAyC;AAIzC,0CAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,MAAa,OAAQ,SAAQ,MAAM,CAAC,cAAc;IAC9C;;;;;;;OAOG;IACI,MAAM,CAAC,GAAG,CAAC,IAAY,EAAE,EAA2B,EAAE,IAAmC;QAC5F,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,SAAgB,kCAAO,IAAI,KAAE,EAAE,EAAE,EAAE,IAAG,CAAC;IACpE,CAAC;IAKD;;;OAGG;IACI,MAAM,CAAC,UAAU,CAAC,GAAQ;QAC7B,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE;YACnC,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC;IACxD,CAAC;IA4JD;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,IAAkB,EAAE,IAAmC;;QAC7E,IAAI,cAAc,GAAkB,EAAE,CAAC;QACvC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;YACV,cAAc,CAAC,wBAAwB,CAAC,GAAG,MAAA,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CA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QAAQ,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;SAChD;QACD,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,IAAI,CAAC,CAAC;QACnE,MAAM,gBAAgB,GAAG,EAAE,gBAAgB,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/D,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACnD,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;;AAtOL,0BAuOC;AA1NG,gBAAgB;AACO,oBAAY,GAAG,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulumi/command",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"pulumi",
|
|
6
6
|
"command",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "tsc",
|
|
15
|
-
"install": "node scripts/install-pulumi-plugin.js resource command 1.0.0
|
|
15
|
+
"install": "node scripts/install-pulumi-plugin.js resource command 1.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@pulumi/pulumi": "^3.0.0"
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"pulumi": {
|
|
25
25
|
"resource": true,
|
|
26
26
|
"name": "command",
|
|
27
|
-
"version": "1.0.0
|
|
27
|
+
"version": "1.0.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/package.json.dev
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pulumi/command",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"pulumi",
|
|
6
6
|
"command",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"pulumi": {
|
|
24
24
|
"resource": true,
|
|
25
25
|
"name": "command",
|
|
26
|
-
"version": "1.0.0
|
|
26
|
+
"version": "1.0.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/remote/command.d.ts
CHANGED
|
@@ -6,8 +6,31 @@ import * as enums from "../types/enums";
|
|
|
6
6
|
* A command to run on a remote host. The connection is established via ssh.
|
|
7
7
|
*
|
|
8
8
|
* ## Example Usage
|
|
9
|
-
* ### Triggers
|
|
10
9
|
*
|
|
10
|
+
* ### A Basic Example
|
|
11
|
+
* This program connects to a server and runs the `hostname` command. The output is then available via the `stdout` property.
|
|
12
|
+
*
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
15
|
+
* import * as command from "@pulumi/command";
|
|
16
|
+
*
|
|
17
|
+
* const config = new pulumi.Config();
|
|
18
|
+
* const server = config.require("server");
|
|
19
|
+
* const userName = config.require("userName");
|
|
20
|
+
* const privateKey = config.require("privateKey");
|
|
21
|
+
*
|
|
22
|
+
* const hostnameCmd = new command.remote.Command("hostnameCmd", {
|
|
23
|
+
* create: "hostname",
|
|
24
|
+
* connection: {
|
|
25
|
+
* host: server,
|
|
26
|
+
* user: userName,
|
|
27
|
+
* privateKey: privateKey,
|
|
28
|
+
* },
|
|
29
|
+
* });
|
|
30
|
+
* export const hostname = hostnameCmd.stdout;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ### Triggers
|
|
11
34
|
* This example defines several trigger values of various kinds. Changes to any of them will cause `cmd` to be re-run.
|
|
12
35
|
*
|
|
13
36
|
* ```typescript
|
package/remote/command.js
CHANGED
|
@@ -10,8 +10,31 @@ const utilities = require("../utilities");
|
|
|
10
10
|
* A command to run on a remote host. The connection is established via ssh.
|
|
11
11
|
*
|
|
12
12
|
* ## Example Usage
|
|
13
|
-
* ### Triggers
|
|
14
13
|
*
|
|
14
|
+
* ### A Basic Example
|
|
15
|
+
* This program connects to a server and runs the `hostname` command. The output is then available via the `stdout` property.
|
|
16
|
+
*
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
19
|
+
* import * as command from "@pulumi/command";
|
|
20
|
+
*
|
|
21
|
+
* const config = new pulumi.Config();
|
|
22
|
+
* const server = config.require("server");
|
|
23
|
+
* const userName = config.require("userName");
|
|
24
|
+
* const privateKey = config.require("privateKey");
|
|
25
|
+
*
|
|
26
|
+
* const hostnameCmd = new command.remote.Command("hostnameCmd", {
|
|
27
|
+
* create: "hostname",
|
|
28
|
+
* connection: {
|
|
29
|
+
* host: server,
|
|
30
|
+
* user: userName,
|
|
31
|
+
* privateKey: privateKey,
|
|
32
|
+
* },
|
|
33
|
+
* });
|
|
34
|
+
* export const hostname = hostnameCmd.stdout;
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ### Triggers
|
|
15
38
|
* This example defines several trigger values of various kinds. Changes to any of them will cause `cmd` to be re-run.
|
|
16
39
|
*
|
|
17
40
|
* ```typescript
|
package/remote/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../remote/command.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,iFAAiF;;;AAEjF,yCAAyC;AACzC,yCAAyC;AAGzC,0CAA0C;AAE1C
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../remote/command.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,iFAAiF;;;AAEjF,yCAAyC;AACzC,yCAAyC;AAGzC,0CAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAa,OAAQ,SAAQ,MAAM,CAAC,cAAc;IAC9C;;;;;;;OAOG;IACI,MAAM,CAAC,GAAG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,CAAC,OAAO,CAAC;YAC9C,cAAc,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC7C,cAAc,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC5C,cAAc,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC7C,cAAc,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;YAC/C,cAAc,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;SAChD;QACD,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,oBAAoB,EAAE,EAAE,IAAI,CAAC,CAAC;QACnE,MAAM,UAAU,GAAG,EAAE,uBAAuB,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;QAC/D,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC7C,MAAM,gBAAgB,GAAG,EAAE,gBAAgB,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC;QAC/D,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;QACnD,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;;AAnIL,0BAoIC;AAvHG,gBAAgB;AACO,oBAAY,GAAG,wBAAwB,CAAC"}
|
package/remote/copyToRemote.d.ts
CHANGED
|
@@ -3,6 +3,64 @@ import * as inputs from "../types/input";
|
|
|
3
3
|
import * as outputs from "../types/output";
|
|
4
4
|
/**
|
|
5
5
|
* Copy an Asset or Archive to a remote host.
|
|
6
|
+
*
|
|
7
|
+
* ## Example usage
|
|
8
|
+
*
|
|
9
|
+
* 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.
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
13
|
+
* import { remote, types } from "@pulumi/command";
|
|
14
|
+
* import * as fs from "fs";
|
|
15
|
+
* import * as os from "os";
|
|
16
|
+
* import * as path from "path";
|
|
17
|
+
*
|
|
18
|
+
* export = async () => {
|
|
19
|
+
* const config = new pulumi.Config();
|
|
20
|
+
*
|
|
21
|
+
* // Get the private key to connect to the server. If a key is
|
|
22
|
+
* // provided, use it, otherwise default to the standard id_rsa SSH key.
|
|
23
|
+
* const privateKeyBase64 = config.get("privateKeyBase64");
|
|
24
|
+
* const privateKey = privateKeyBase64 ?
|
|
25
|
+
* Buffer.from(privateKeyBase64, 'base64').toString('ascii') :
|
|
26
|
+
* fs.readFileSync(path.join(os.homedir(), ".ssh", "id_rsa")).toString("utf8");
|
|
27
|
+
*
|
|
28
|
+
* const serverPublicIp = config.require("serverPublicIp");
|
|
29
|
+
* const userName = config.require("userName");
|
|
30
|
+
*
|
|
31
|
+
* // The configuration of our SSH connection to the instance.
|
|
32
|
+
* const connection: types.input.remote.ConnectionArgs = {
|
|
33
|
+
* host: serverPublicIp,
|
|
34
|
+
* user: userName,
|
|
35
|
+
* privateKey: privateKey,
|
|
36
|
+
* };
|
|
37
|
+
*
|
|
38
|
+
* // Set up source and target of the remote copy.
|
|
39
|
+
* const from = config.require("payload")!;
|
|
40
|
+
* const archive = new pulumi.asset.FileArchive(from);
|
|
41
|
+
* const to = config.require("destDir")!;
|
|
42
|
+
*
|
|
43
|
+
* // Copy the files to the remote.
|
|
44
|
+
* const copy = new remote.CopyToRemote("copy", {
|
|
45
|
+
* connection,
|
|
46
|
+
* source: archive,
|
|
47
|
+
* remotePath: to,
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Verify that the expected files were copied to the remote.
|
|
51
|
+
* // We want to run this after each copy, i.e., when something changed,
|
|
52
|
+
* // so we use the asset to be copied as a trigger.
|
|
53
|
+
* const find = new remote.Command("ls", {
|
|
54
|
+
* connection,
|
|
55
|
+
* create: `find ${to}/${from} | sort`,
|
|
56
|
+
* triggers: [archive],
|
|
57
|
+
* }, { dependsOn: copy });
|
|
58
|
+
*
|
|
59
|
+
* return {
|
|
60
|
+
* remoteContents: find.stdout
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
6
64
|
*/
|
|
7
65
|
export declare class CopyToRemote extends pulumi.CustomResource {
|
|
8
66
|
/**
|
package/remote/copyToRemote.js
CHANGED
|
@@ -8,6 +8,64 @@ const inputs = require("../types/input");
|
|
|
8
8
|
const utilities = require("../utilities");
|
|
9
9
|
/**
|
|
10
10
|
* Copy an Asset or Archive to a remote host.
|
|
11
|
+
*
|
|
12
|
+
* ## Example usage
|
|
13
|
+
*
|
|
14
|
+
* 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.
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import * as pulumi from "@pulumi/pulumi";
|
|
18
|
+
* import { remote, types } from "@pulumi/command";
|
|
19
|
+
* import * as fs from "fs";
|
|
20
|
+
* import * as os from "os";
|
|
21
|
+
* import * as path from "path";
|
|
22
|
+
*
|
|
23
|
+
* export = async () => {
|
|
24
|
+
* const config = new pulumi.Config();
|
|
25
|
+
*
|
|
26
|
+
* // Get the private key to connect to the server. If a key is
|
|
27
|
+
* // provided, use it, otherwise default to the standard id_rsa SSH key.
|
|
28
|
+
* const privateKeyBase64 = config.get("privateKeyBase64");
|
|
29
|
+
* const privateKey = privateKeyBase64 ?
|
|
30
|
+
* Buffer.from(privateKeyBase64, 'base64').toString('ascii') :
|
|
31
|
+
* fs.readFileSync(path.join(os.homedir(), ".ssh", "id_rsa")).toString("utf8");
|
|
32
|
+
*
|
|
33
|
+
* const serverPublicIp = config.require("serverPublicIp");
|
|
34
|
+
* const userName = config.require("userName");
|
|
35
|
+
*
|
|
36
|
+
* // The configuration of our SSH connection to the instance.
|
|
37
|
+
* const connection: types.input.remote.ConnectionArgs = {
|
|
38
|
+
* host: serverPublicIp,
|
|
39
|
+
* user: userName,
|
|
40
|
+
* privateKey: privateKey,
|
|
41
|
+
* };
|
|
42
|
+
*
|
|
43
|
+
* // Set up source and target of the remote copy.
|
|
44
|
+
* const from = config.require("payload")!;
|
|
45
|
+
* const archive = new pulumi.asset.FileArchive(from);
|
|
46
|
+
* const to = config.require("destDir")!;
|
|
47
|
+
*
|
|
48
|
+
* // Copy the files to the remote.
|
|
49
|
+
* const copy = new remote.CopyToRemote("copy", {
|
|
50
|
+
* connection,
|
|
51
|
+
* source: archive,
|
|
52
|
+
* remotePath: to,
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Verify that the expected files were copied to the remote.
|
|
56
|
+
* // We want to run this after each copy, i.e., when something changed,
|
|
57
|
+
* // so we use the asset to be copied as a trigger.
|
|
58
|
+
* const find = new remote.Command("ls", {
|
|
59
|
+
* connection,
|
|
60
|
+
* create: `find ${to}/${from} | sort`,
|
|
61
|
+
* triggers: [archive],
|
|
62
|
+
* }, { dependsOn: copy });
|
|
63
|
+
*
|
|
64
|
+
* return {
|
|
65
|
+
* remoteContents: find.stdout
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
11
69
|
*/
|
|
12
70
|
class CopyToRemote extends pulumi.CustomResource {
|
|
13
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyToRemote.js","sourceRoot":"","sources":["../../remote/copyToRemote.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,iFAAiF;;;AAEjF,yCAAyC;AACzC,yCAAyC;AAGzC,0CAA0C;AAE1C
|
|
1
|
+
{"version":3,"file":"copyToRemote.js","sourceRoot":"","sources":["../../remote/copyToRemote.ts"],"names":[],"mappings":";AAAA,sEAAsE;AACtE,iFAAiF;;;AAEjF,yCAAyC;AACzC,yCAAyC;AAGzC,0CAA0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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