1. Packages
  2. Command
  3. API Docs
  4. local
  5. Command
Command v1.0.1 published on Thursday, Jul 18, 2024 by Pulumi

command.local.Command

Explore with Pulumi AI

command logo
Command v1.0.1 published on Thursday, Jul 18, 2024 by Pulumi

    A local command to be executed.

    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.

    Example Usage

    Basic Example

    using System.Collections.Generic;
    using Pulumi;
    using Pulumi.Command.Local;
    
    await Deployment.RunAsync(() =>
    {
        var command = new Command("random", new CommandArgs
        {
            Create = "openssl rand -hex 16"
        });
    
        return new Dictionary<string, object?>
        {
            ["stdOut"] = command.Stdout
        };
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-command/sdk/go/command/local"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		random, err := local.NewCommand(ctx, "my-bucket", &local.CommandArgs{
    			Create: pulumi.String("openssl rand -hex 16"),
    		})
    		if err != nil {
    			return err
    		}
    
    		ctx.Export("output", random.Stdout)
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.command.local.Command;
    import com.pulumi.command.local.CommandArgs;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var random = new Command("random", CommandArgs.builder()
                .create("openssl rand -hex 16")
                .build());
    
            ctx.export("rand", random.stdout());
        }
    }
    
    import pulumi
    from pulumi_command import local
    
    random = local.Command("random",
        create="openssl rand -hex 16"
    )
    
    pulumi.export("random", random.stdout)
    
    import { local } from "@pulumi/command";
    
    const random = new local.Command("random", {
        create: "openssl rand -hex 16",
    });
    
    export const output = random.stdout;
    
    outputs:
      rand: "${random.stdout}"
    resources:
      random:
        type: command:local:Command
        properties:
          create: "openssl rand -hex 16"
    

    Invoking a Lambda during Pulumi Deployment

    using System.Collections.Generic;
    using System.Text.Json;
    using Pulumi;
    using Aws = Pulumi.Aws;
    using Command = Pulumi.Command;
    
    return await Deployment.RunAsync(() => 
    {
        var awsConfig = new Config("aws");
    
        var lambdaRole = new Aws.Iam.Role("lambdaRole", new()
        {
            AssumeRolePolicy = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["Version"] = "2012-10-17",
                ["Statement"] = new[]
                {
                    new Dictionary<string, object?>
                    {
                        ["Action"] = "sts:AssumeRole",
                        ["Effect"] = "Allow",
                        ["Principal"] = new Dictionary<string, object?>
                        {
                            ["Service"] = "lambda.amazonaws.com",
                        },
                    },
                },
            }),
        });
    
        var lambdaFunction = new Aws.Lambda.Function("lambdaFunction", new()
        {
            Name = "f",
            Publish = true,
            Role = lambdaRole.Arn,
            Handler = "index.handler",
            Runtime = Aws.Lambda.Runtime.NodeJS20dX,
            Code = new FileArchive("./handler"),
        });
    
        var invokeCommand = new Command.Local.Command("invokeCommand", new()
        {
            Create = $"aws lambda invoke --function-name \"$FN\" --payload '{{\"stackName\": \"{Deployment.Instance.StackName}\"}}' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d '\"'  && rm out.txt",
            Environment = 
            {
                { "FN", lambdaFunction.Arn },
                { "AWS_REGION", awsConfig.Require("region") },
                { "AWS_PAGER", "" },
            },
        }, new CustomResourceOptions
        {
            DependsOn =
            {
                lambdaFunction,
            },
        });
    
        return new Dictionary<string, object?>
        {
            ["output"] = invokeCommand.Stdout,
        };
    });
    
    package main
    
    import (
    	"encoding/json"
    	"fmt"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda"
    	"github.com/pulumi/pulumi-command/sdk/go/command/local"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		awsConfig := config.New(ctx, "aws")
    		awsRegion := awsConfig.Require("region")
    
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"Version": "2012-10-17",
    			"Statement": []map[string]interface{}{
    				{
    					"Action": "sts:AssumeRole",
    					"Effect": "Allow",
    					"Principal": map[string]interface{}{
    						"Service": "lambda.amazonaws.com",
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		lambdaRole, err := iam.NewRole(ctx, "lambdaRole", &iam.RoleArgs{
    			AssumeRolePolicy: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		lambdaFunction, err := lambda.NewFunction(ctx, "lambdaFunction", &lambda.FunctionArgs{
    			Name:    pulumi.String("f"),
    			Publish: pulumi.Bool(true),
    			Role:    lambdaRole.Arn,
    			Handler: pulumi.String("index.handler"),
    			Runtime: pulumi.String(lambda.RuntimeNodeJS20dX),
    			Code:    pulumi.NewFileArchive("./handler"),
    		})
    		if err != nil {
    			return err
    		}
    		invokeCommand, err := local.NewCommand(ctx, "invokeCommand", &local.CommandArgs{
    			Create: pulumi.String(fmt.Sprintf("aws lambda invoke --function-name \"$FN\" --payload '{\"stackName\": \"%v\"}' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d '\"'  && rm out.txt", ctx.Stack())),
    			Environment: pulumi.StringMap{
    				"FN":         lambdaFunction.Arn,
    				"AWS_REGION": pulumi.String(awsRegion),
    				"AWS_PAGER":  pulumi.String(""),
    			},
    		}, pulumi.DependsOn([]pulumi.Resource{
    			lambdaFunction,
    		}))
    		if err != nil {
    			return err
    		}
    		ctx.Export("output", invokeCommand.Stdout)
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.aws.iam.Role;
    import com.pulumi.aws.iam.RoleArgs;
    import com.pulumi.aws.lambda.Function;
    import com.pulumi.aws.lambda.FunctionArgs;
    import com.pulumi.command.local.Command;
    import com.pulumi.command.local.CommandArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    import com.pulumi.resources.CustomResourceOptions;
    import com.pulumi.asset.FileArchive;
    import java.util.Map;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var awsConfig = ctx.config("aws");
            var awsRegion = awsConfig.require("region");
    
            var lambdaRole = new Role("lambdaRole", RoleArgs.builder()
                    .assumeRolePolicy(serializeJson(
                            jsonObject(
                                    jsonProperty("Version", "2012-10-17"),
                                    jsonProperty("Statement", jsonArray(jsonObject(
                                            jsonProperty("Action", "sts:AssumeRole"),
                                            jsonProperty("Effect", "Allow"),
                                            jsonProperty("Principal", jsonObject(
                                                    jsonProperty("Service", "lambda.amazonaws.com")))))))))
                    .build());
    
            var lambdaFunction = new Function("lambdaFunction", FunctionArgs.builder()
                    .name("f")
                    .publish(true)
                    .role(lambdaRole.arn())
                    .handler("index.handler")
                    .runtime("nodejs20.x")
                    .code(new FileArchive("./handler"))
                    .build());
    
            // Work around the lack of Output.all for Maps in Java. We cannot use a plain Map because
            // `lambdaFunction.arn()` is an Output<String>.
            var invokeEnv = Output.tuple(
                    Output.of("FN"), lambdaFunction.arn(),
                    Output.of("AWS_REGION"), Output.of(awsRegion),
                    Output.of("AWS_PAGER"), Output.of("")
            ).applyValue(t -> Map.of(t.t1, t.t2, t.t3, t.t4, t.t5, t.t6));
    
            var invokeCommand = new Command("invokeCommand", CommandArgs.builder()
                    .create(String.format(
                            "aws lambda invoke --function-name \"$FN\" --payload '{\"stackName\": \"%s\"}' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d '\"'  && rm out.txt",
                            ctx.stackName()))
                    .environment(invokeEnv)
                    .build(),
                    CustomResourceOptions.builder()
                            .dependsOn(lambdaFunction)
                            .build());
    
            ctx.export("output", invokeCommand.stdout());
        }
    }
    
    import pulumi
    import json
    import pulumi_aws as aws
    import pulumi_command as command
    
    lambda_role = aws.iam.Role("lambdaRole", assume_role_policy=json.dumps({
        "Version": "2012-10-17",
        "Statement": [{
            "Action": "sts:AssumeRole",
            "Effect": "Allow",
            "Principal": {
                "Service": "lambda.amazonaws.com",
            },
        }],
    }))
    
    lambda_function = aws.lambda_.Function("lambdaFunction",
        name="f",
        publish=True,
        role=lambda_role.arn,
        handler="index.handler",
        runtime=aws.lambda_.Runtime.NODE_JS20D_X,
        code=pulumi.FileArchive("./handler"))
    
    aws_config = pulumi.Config("aws")
    aws_region = aws_config.require("region")
    
    invoke_command = command.local.Command("invokeCommand",
        create=f"aws lambda invoke --function-name \"$FN\" --payload '{{\"stackName\": \"{pulumi.get_stack()}\"}}' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d '\"'  && rm out.txt",
        environment={
            "FN": lambda_function.arn,
            "AWS_REGION": aws_region,
            "AWS_PAGER": "",
        },
        opts = pulumi.ResourceOptions(depends_on=[lambda_function]))
    
    pulumi.export("output", invoke_command.stdout)
    
    import * as aws from "@pulumi/aws";
    import { local } from "@pulumi/command";
    import { getStack } from "@pulumi/pulumi";
    
    const f = new aws.lambda.CallbackFunction("f", {
        publish: true,
        callback: async (ev: any) => {
            return `Stack ${ev.stackName} is deployed!`;
        }
    });
    
    const invoke = new local.Command("execf", {
        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`,
        environment: {
            FN: f.qualifiedArn,
            AWS_REGION: aws.config.region!,
            AWS_PAGER: "",
        },
    }, { dependsOn: f })
    
    export const output = invoke.stdout;
    
    resources:
      lambdaRole:
        type: aws:iam:Role
        properties:
          assumeRolePolicy:
            fn::toJSON:
              Version: "2012-10-17"
              Statement:
                - Action: sts:AssumeRole
                  Effect: Allow
                  Principal:
                    Service: lambda.amazonaws.com
    
      lambdaFunction:
        type: aws:lambda:Function
        properties:
          name: f
          publish: true
          role: ${lambdaRole.arn}
          handler: index.handler
          runtime: "nodejs20.x"
          code:
            fn::fileArchive: ./handler
    
      invokeCommand:
        type: command:local:Command
        properties:
          create: 'aws lambda invoke --function-name "$FN" --payload ''{"stackName": "${pulumi.stack}"}'' --cli-binary-format raw-in-base64-out out.txt >/dev/null && cat out.txt | tr -d ''"''  && rm out.txt'
          environment:
            FN: ${lambdaFunction.arn}
            AWS_REGION: ${aws:region}
            AWS_PAGER: ""
        options:
          dependsOn:
            - ${lambdaFunction}
    
    outputs:
      output: ${invokeCommand.stdout}
    

    Using Triggers

    using Pulumi;
    using Command = Pulumi.Command;
    using Random = Pulumi.Random;
    
    return await Deployment.RunAsync(() =>
    {
        var str = "foo";
    
        var fileAssetVar = new FileAsset("Pulumi.yaml");
    
        var rand = new Random.RandomString("rand", new()
        {
            Length = 5,
        });
    
        var localFile = new Command.Local.Command("localFile", new()
        {
            Create = "touch foo.txt",
            ArchivePaths = new[]
            {
                "*.txt",
            },
        });
    
        var cmd = new Command.Local.Command("cmd", new()
        {
            Create = "echo create > op.txt",
            Delete = "echo delete >> op.txt",
            Triggers = new object[]
            {
                str,
                rand.Result,
                fileAssetVar,
                localFile.Archive,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-command/sdk/go/command/local"
    	"github.com/pulumi/pulumi-random/sdk/v4/go/random"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		str := pulumi.String("foo")
    
    		fileAsset := pulumi.NewFileAsset("Pulumi.yaml")
    
    		rand, err := random.NewRandomString(ctx, "rand", &random.RandomStringArgs{
    			Length: pulumi.Int(5),
    		})
    		if err != nil {
    			return err
    		}
    
    		localFile, err := local.NewCommand(ctx, "localFile", &local.CommandArgs{
    			Create: pulumi.String("touch foo.txt"),
    			ArchivePaths: pulumi.StringArray{
    				pulumi.String("*.txt"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    
    		_, err = local.NewCommand(ctx, "cmd", &local.CommandArgs{
    			Create: pulumi.String("echo create > op.txt"),
    			Delete: pulumi.String("echo delete >> op.txt"),
    			Triggers: pulumi.Array{
    				str,
    				rand.Result,
    				fileAsset,
    				localFile.Archive,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var fileAssetVar = new FileAsset("Pulumi.yaml");
    
            var rand = new RandomString("rand", RandomStringArgs.builder()
                .length(5)
                .build());
    
            var localFile = new Command("localFile", CommandArgs.builder()
                .create("touch foo.txt")
                .archivePaths("*.txt")
                .build());
    
            var cmd = new Command("cmd", CommandArgs.builder()
                .create("echo create > op.txt")
                .delete("echo delete >> op.txt")
                .triggers(
                    rand.result(),
                    fileAssetVar,
                    localFile.archive())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_command as command
    import pulumi_random as random
    
    foo = "foo"
    file_asset_var = pulumi.FileAsset("Pulumi.yaml")
    rand = random.RandomString("rand", length=5)
    local_file = command.local.Command("localFile",
        create="touch foo.txt",
        archive_paths=["*.txt"])
    
    cmd = command.local.Command("cmd",
        create="echo create > op.txt",
        delete="echo delete >> op.txt",
        triggers=[
            foo,
            rand.result,
            file_asset_var,
            local_file.archive,
        ])
    
    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.local.Command("cmd", {
        create: "echo create > op.txt",
        delete: "echo delete >> op.txt",
        triggers: [
            str,
            rand.result,
            fileAsset,
            localFile.archive,
        ],
    });
    
    config: {}
    outputs: {}
    resources:
      rand:
        type: random:index/randomString:RandomString
        properties:
          length: 5
    
      localFile:
        type: command:local:Command
        properties:
          create: touch foo.txt
          archivePaths:
            - "*.txt"
    
      cmd:
        type: command:local:Command
        properties:
          create: echo create > op.txt
          delete: echo delete >> op.txt
          triggers:
            - ${rand.result}
            - ${fileAsset}
            - ${localFile.archive}
    
    variables:
      fileAsset:
        fn::fileAsset: "Pulumi.yaml"
    

    Create Command Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new Command(name: string, args?: CommandArgs, opts?: CustomResourceOptions);
    @overload
    def Command(resource_name: str,
                args: Optional[CommandArgs] = None,
                opts: Optional[ResourceOptions] = None)
    
    @overload
    def Command(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                add_previous_output_in_env: Optional[bool] = None,
                archive_paths: Optional[Sequence[str]] = None,
                asset_paths: Optional[Sequence[str]] = None,
                create: Optional[str] = None,
                delete: Optional[str] = None,
                dir: Optional[str] = None,
                environment: Optional[Mapping[str, str]] = None,
                interpreter: Optional[Sequence[str]] = None,
                logging: Optional[Logging] = None,
                stdin: Optional[str] = None,
                triggers: Optional[Sequence[Any]] = None,
                update: Optional[str] = None)
    func NewCommand(ctx *Context, name string, args *CommandArgs, opts ...ResourceOption) (*Command, error)
    public Command(string name, CommandArgs? args = null, CustomResourceOptions? opts = null)
    public Command(String name, CommandArgs args)
    public Command(String name, CommandArgs args, CustomResourceOptions options)
    
    type: command:local:Command
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args CommandArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args CommandArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args CommandArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args CommandArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args CommandArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var commandResource = new Command.Local.Command("commandResource", new()
    {
        AddPreviousOutputInEnv = false,
        ArchivePaths = new[]
        {
            "string",
        },
        AssetPaths = new[]
        {
            "string",
        },
        Create = "string",
        Delete = "string",
        Dir = "string",
        Environment = 
        {
            { "string", "string" },
        },
        Interpreter = new[]
        {
            "string",
        },
        Logging = Command.Local.Logging.Stdout,
        Stdin = "string",
        Triggers = new[]
        {
            "any",
        },
        Update = "string",
    });
    
    example, err := local.NewCommand(ctx, "commandResource", &local.CommandArgs{
    	AddPreviousOutputInEnv: pulumi.Bool(false),
    	ArchivePaths: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	AssetPaths: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Create: pulumi.String("string"),
    	Delete: pulumi.String("string"),
    	Dir:    pulumi.String("string"),
    	Environment: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Interpreter: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Logging: local.LoggingStdout,
    	Stdin:   pulumi.String("string"),
    	Triggers: pulumi.Array{
    		pulumi.Any("any"),
    	},
    	Update: pulumi.String("string"),
    })
    
    var commandResource = new Command("commandResource", CommandArgs.builder()
        .addPreviousOutputInEnv(false)
        .archivePaths("string")
        .assetPaths("string")
        .create("string")
        .delete("string")
        .dir("string")
        .environment(Map.of("string", "string"))
        .interpreter("string")
        .logging("stdout")
        .stdin("string")
        .triggers("any")
        .update("string")
        .build());
    
    command_resource = command.local.Command("commandResource",
        add_previous_output_in_env=False,
        archive_paths=["string"],
        asset_paths=["string"],
        create="string",
        delete="string",
        dir="string",
        environment={
            "string": "string",
        },
        interpreter=["string"],
        logging=command.local.Logging.STDOUT,
        stdin="string",
        triggers=["any"],
        update="string")
    
    const commandResource = new command.local.Command("commandResource", {
        addPreviousOutputInEnv: false,
        archivePaths: ["string"],
        assetPaths: ["string"],
        create: "string",
        "delete": "string",
        dir: "string",
        environment: {
            string: "string",
        },
        interpreter: ["string"],
        logging: command.local.Logging.Stdout,
        stdin: "string",
        triggers: ["any"],
        update: "string",
    });
    
    type: command:local:Command
    properties:
        addPreviousOutputInEnv: false
        archivePaths:
            - string
        assetPaths:
            - string
        create: string
        delete: string
        dir: string
        environment:
            string: string
        interpreter:
            - string
        logging: stdout
        stdin: string
        triggers:
            - any
        update: string
    

    Command Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The Command resource accepts the following input properties:

    AddPreviousOutputInEnv bool
    If the previous command's stdout and stderr (as generated by the prior create/update) is injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. Defaults to true.
    ArchivePaths List<string>

    A list of path globs to return as a single archive asset after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    AssetPaths List<string>

    A list of path globs to read after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    Create string
    The command to run on create.
    Delete string
    The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    Dir string
    The directory from which to run the command from. If dir does not exist, then Command will fail.
    Environment Dictionary<string, string>
    Additional environment variables available to the command's process.
    Interpreter List<string>
    The program and arguments to run the command. On Linux and macOS, defaults to: ["/bin/sh", "-c"]. On Windows, defaults to: ["cmd", "/C"]
    Logging Pulumi.Command.Local.Logging
    If the command's stdout and stderr should be logged. This doesn't affect the capturing of stdout and stderr as outputs. If there might be secrets in the output, you can disable logging here and mark the outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout and stderr.
    Stdin string
    Pass a string to the command's process as standard in
    Triggers List<object>
    Trigger a resource replacement on changes to any of these values. The trigger values can be of any type. If a value is different in the current update compared to the previous update, the resource will be replaced, i.e., the "create" command will be re-run. Please see the resource documentation for examples.
    Update string
    The command to run on update, if empty, create will run again. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    AddPreviousOutputInEnv bool
    If the previous command's stdout and stderr (as generated by the prior create/update) is injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. Defaults to true.
    ArchivePaths []string

    A list of path globs to return as a single archive asset after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    AssetPaths []string

    A list of path globs to read after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    Create string
    The command to run on create.
    Delete string
    The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    Dir string
    The directory from which to run the command from. If dir does not exist, then Command will fail.
    Environment map[string]string
    Additional environment variables available to the command's process.
    Interpreter []string
    The program and arguments to run the command. On Linux and macOS, defaults to: ["/bin/sh", "-c"]. On Windows, defaults to: ["cmd", "/C"]
    Logging Logging
    If the command's stdout and stderr should be logged. This doesn't affect the capturing of stdout and stderr as outputs. If there might be secrets in the output, you can disable logging here and mark the outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout and stderr.
    Stdin string
    Pass a string to the command's process as standard in
    Triggers []interface{}
    Trigger a resource replacement on changes to any of these values. The trigger values can be of any type. If a value is different in the current update compared to the previous update, the resource will be replaced, i.e., the "create" command will be re-run. Please see the resource documentation for examples.
    Update string
    The command to run on update, if empty, create will run again. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    addPreviousOutputInEnv Boolean
    If the previous command's stdout and stderr (as generated by the prior create/update) is injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. Defaults to true.
    archivePaths List<String>

    A list of path globs to return as a single archive asset after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    assetPaths List<String>

    A list of path globs to read after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    create String
    The command to run on create.
    delete String
    The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    dir String
    The directory from which to run the command from. If dir does not exist, then Command will fail.
    environment Map<String,String>
    Additional environment variables available to the command's process.
    interpreter List<String>
    The program and arguments to run the command. On Linux and macOS, defaults to: ["/bin/sh", "-c"]. On Windows, defaults to: ["cmd", "/C"]
    logging Logging
    If the command's stdout and stderr should be logged. This doesn't affect the capturing of stdout and stderr as outputs. If there might be secrets in the output, you can disable logging here and mark the outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout and stderr.
    stdin String
    Pass a string to the command's process as standard in
    triggers List<Object>
    Trigger a resource replacement on changes to any of these values. The trigger values can be of any type. If a value is different in the current update compared to the previous update, the resource will be replaced, i.e., the "create" command will be re-run. Please see the resource documentation for examples.
    update String
    The command to run on update, if empty, create will run again. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    addPreviousOutputInEnv boolean
    If the previous command's stdout and stderr (as generated by the prior create/update) is injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. Defaults to true.
    archivePaths string[]

    A list of path globs to return as a single archive asset after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    assetPaths string[]

    A list of path globs to read after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    create string
    The command to run on create.
    delete string
    The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    dir string
    The directory from which to run the command from. If dir does not exist, then Command will fail.
    environment {[key: string]: string}
    Additional environment variables available to the command's process.
    interpreter string[]
    The program and arguments to run the command. On Linux and macOS, defaults to: ["/bin/sh", "-c"]. On Windows, defaults to: ["cmd", "/C"]
    logging Logging
    If the command's stdout and stderr should be logged. This doesn't affect the capturing of stdout and stderr as outputs. If there might be secrets in the output, you can disable logging here and mark the outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout and stderr.
    stdin string
    Pass a string to the command's process as standard in
    triggers any[]
    Trigger a resource replacement on changes to any of these values. The trigger values can be of any type. If a value is different in the current update compared to the previous update, the resource will be replaced, i.e., the "create" command will be re-run. Please see the resource documentation for examples.
    update string
    The command to run on update, if empty, create will run again. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    add_previous_output_in_env bool
    If the previous command's stdout and stderr (as generated by the prior create/update) is injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. Defaults to true.
    archive_paths Sequence[str]

    A list of path globs to return as a single archive asset after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    asset_paths Sequence[str]

    A list of path globs to read after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    create str
    The command to run on create.
    delete str
    The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    dir str
    The directory from which to run the command from. If dir does not exist, then Command will fail.
    environment Mapping[str, str]
    Additional environment variables available to the command's process.
    interpreter Sequence[str]
    The program and arguments to run the command. On Linux and macOS, defaults to: ["/bin/sh", "-c"]. On Windows, defaults to: ["cmd", "/C"]
    logging Logging
    If the command's stdout and stderr should be logged. This doesn't affect the capturing of stdout and stderr as outputs. If there might be secrets in the output, you can disable logging here and mark the outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout and stderr.
    stdin str
    Pass a string to the command's process as standard in
    triggers Sequence[Any]
    Trigger a resource replacement on changes to any of these values. The trigger values can be of any type. If a value is different in the current update compared to the previous update, the resource will be replaced, i.e., the "create" command will be re-run. Please see the resource documentation for examples.
    update str
    The command to run on update, if empty, create will run again. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    addPreviousOutputInEnv Boolean
    If the previous command's stdout and stderr (as generated by the prior create/update) is injected into the environment of the next run as PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR. Defaults to true.
    archivePaths List<String>

    A list of path globs to return as a single archive asset after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    assetPaths List<String>

    A list of path globs to read after the command completes.

    When specifying glob patterns the following rules apply:

    • We only include files not directories for assets and archives.
    • Path separators are / on all platforms - including Windows.
    • Patterns starting with ! are 'exclude' rules.
    • Rules are evaluated in order, so exclude rules should be after inclusion rules.
    • * matches anything except /
    • ** matches anything, including /
    • All returned paths are relative to the working directory (without leading ./) e.g. file.text or subfolder/file.txt.
    • For full details of the globbing syntax, see github.com/gobwas/glob

    Example

    Given the rules:

    - "assets/**"
    - "src/**.js"
    - "!**secret.*"
    

    When evaluating against this folder:

    - assets/
      - logos/
        - logo.svg
    - src/
      - index.js
      - secret.js
    

    The following paths will be returned:

    - assets/logos/logo.svg
    - src/index.js
    
    create String
    The command to run on create.
    delete String
    The command to run on delete. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.
    dir String
    The directory from which to run the command from. If dir does not exist, then Command will fail.
    environment Map<String>
    Additional environment variables available to the command's process.
    interpreter List<String>
    The program and arguments to run the command. On Linux and macOS, defaults to: ["/bin/sh", "-c"]. On Windows, defaults to: ["cmd", "/C"]
    logging "stdout" | "stderr" | "stdoutAndStderr" | "none"
    If the command's stdout and stderr should be logged. This doesn't affect the capturing of stdout and stderr as outputs. If there might be secrets in the output, you can disable logging here and mark the outputs as secret via 'additionalSecretOutputs'. Defaults to logging both stdout and stderr.
    stdin String
    Pass a string to the command's process as standard in
    triggers List<Any>
    Trigger a resource replacement on changes to any of these values. The trigger values can be of any type. If a value is different in the current update compared to the previous update, the resource will be replaced, i.e., the "create" command will be re-run. Please see the resource documentation for examples.
    update String
    The command to run on update, if empty, create will run again. The environment variables PULUMI_COMMAND_STDOUT and PULUMI_COMMAND_STDERR are set to the stdout and stderr properties of the Command resource from previous create or update steps.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the Command resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Stderr string
    The standard error of the command's process
    Stdout string
    The standard output of the command's process
    Archive Archive
    An archive asset containing files found after running the command.
    Assets Dictionary<string, AssetOrArchive>
    A map of assets found after running the command. The key is the relative path from the command dir
    Id string
    The provider-assigned unique ID for this managed resource.
    Stderr string
    The standard error of the command's process
    Stdout string
    The standard output of the command's process
    Archive pulumi.Archive
    An archive asset containing files found after running the command.
    Assets AssetOrArchive
    A map of assets found after running the command. The key is the relative path from the command dir
    id String
    The provider-assigned unique ID for this managed resource.
    stderr String
    The standard error of the command's process
    stdout String
    The standard output of the command's process
    archive Archive
    An archive asset containing files found after running the command.
    assets Map<String,AssetOrArchive>
    A map of assets found after running the command. The key is the relative path from the command dir
    id string
    The provider-assigned unique ID for this managed resource.
    stderr string
    The standard error of the command's process
    stdout string
    The standard output of the command's process
    archive pulumi.asset.Archive
    An archive asset containing files found after running the command.
    assets {[key: string]: pulumi.asset.Asset | pulumi.asset.Archive}
    A map of assets found after running the command. The key is the relative path from the command dir
    id str
    The provider-assigned unique ID for this managed resource.
    stderr str
    The standard error of the command's process
    stdout str
    The standard output of the command's process
    archive pulumi.Archive
    An archive asset containing files found after running the command.
    assets Mapping[str, Union[pulumi.Asset, pulumi.Archive]]
    A map of assets found after running the command. The key is the relative path from the command dir
    id String
    The provider-assigned unique ID for this managed resource.
    stderr String
    The standard error of the command's process
    stdout String
    The standard output of the command's process
    archive Archive
    An archive asset containing files found after running the command.
    assets Map<Asset>
    A map of assets found after running the command. The key is the relative path from the command dir

    Supporting Types

    Logging, LoggingArgs

    Stdout
    stdoutCapture stdout in logs but not stderr
    Stderr
    stderrCapture stderr in logs but not stdout
    StdoutAndStderr
    stdoutAndStderrCapture stdout and stderr in logs
    None
    noneCapture no logs
    LoggingStdout
    stdoutCapture stdout in logs but not stderr
    LoggingStderr
    stderrCapture stderr in logs but not stdout
    LoggingStdoutAndStderr
    stdoutAndStderrCapture stdout and stderr in logs
    LoggingNone
    noneCapture no logs
    Stdout
    stdoutCapture stdout in logs but not stderr
    Stderr
    stderrCapture stderr in logs but not stdout
    StdoutAndStderr
    stdoutAndStderrCapture stdout and stderr in logs
    None
    noneCapture no logs
    Stdout
    stdoutCapture stdout in logs but not stderr
    Stderr
    stderrCapture stderr in logs but not stdout
    StdoutAndStderr
    stdoutAndStderrCapture stdout and stderr in logs
    None
    noneCapture no logs
    STDOUT
    stdoutCapture stdout in logs but not stderr
    STDERR
    stderrCapture stderr in logs but not stdout
    STDOUT_AND_STDERR
    stdoutAndStderrCapture stdout and stderr in logs
    NONE
    noneCapture no logs
    "stdout"
    stdoutCapture stdout in logs but not stderr
    "stderr"
    stderrCapture stderr in logs but not stdout
    "stdoutAndStderr"
    stdoutAndStderrCapture stdout and stderr in logs
    "none"
    noneCapture no logs

    Package Details

    Repository
    command pulumi/pulumi-command
    License
    Apache-2.0
    command logo
    Command v1.0.1 published on Thursday, Jul 18, 2024 by Pulumi