{"id":2670,"library":"pulumi-command","title":"Pulumi Command Provider","description":"The Pulumi Command Provider allows users to execute commands and scripts, either locally or remotely, as part of their Pulumi infrastructure-as-code deployments. It integrates command execution directly into the Pulumi resource model, enabling complex provisioning tasks. The current version is 1.2.1, and the library generally follows a minor point release cadence for bug fixes and feature enhancements, with major versions indicating potential breaking changes.","status":"active","version":"1.2.1","language":"en","source_language":"en","source_url":"https://github.com/pulumi/pulumi-command","tags":["pulumi","iac","infrastructure-as-code","command execution","devops","automation","local command","remote command"],"install":[{"cmd":"pip install pulumi-command","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core Pulumi SDK is required for defining and deploying resources.","package":"pulumi"}],"imports":[{"note":"The `local` module is usually imported directly for its functionality, rather than importing `Command` specifically.","wrong":"from pulumi_command.local import Command","symbol":"local.Command","correct":"from pulumi_command import local"},{"note":"Similar to `local`, the `remote` module is typically imported for its resources.","wrong":"from pulumi_command.remote import Command","symbol":"remote.Command","correct":"from pulumi_command import remote"},{"symbol":"provider.Provider","correct":"from pulumi_command import provider"}],"quickstart":{"code":"import pulumi\nfrom pulumi_command import local\nimport os\n\n# Example of a local command that echoes a message\n# The `triggers` input ensures the command reruns if the message changes.\nlocal_command = local.Command(\"echo-command\",\n    create=\"echo 'Hello from Pulumi local command!'\",\n    triggers=[\"Hello from Pulumi local command!\"] # Ensures re-run on change\n)\n\n# Export the stdout of the command\npulumi.export(\"command_output\", local_command.stdout)\n\n# For remote commands, you'd typically configure SSH:\n# from pulumi_command import remote\n# remote_command = remote.Command(\"remote-script\",\n#     create=\"ls -la\",\n#     connection=remote.ConnectionArgs(\n#         host=\"your_remote_host_ip\",\n#         user=\"your_username\",\n#         private_key=os.environ.get('SSH_PRIVATE_KEY', '') # Use environment variable for sensitive data\n#     )\n# )","lang":"python","description":"This quickstart demonstrates how to define a local command that simply echoes a message. The `triggers` input is crucial for ensuring the command re-runs when its inputs change. It also shows a commented-out section for setting up a remote command, highlighting the need for connection details like host, user, and a private key (preferably from an environment variable for security)."},"warnings":[{"fix":"Explicitly define the `triggers` input for your `local.Command` or `remote.Command` resources. The `triggers` list should contain any values whose changes should cause the command to rerun.","message":"Commands are inherently not idempotent. Without explicit `triggers`, Pulumi won't rerun commands even if their inputs change, leading to potential resource drift. Always specify `triggers` if you want a command to rerun on input changes.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always define a `delete` input for your command resources if they create persistent external resources. The `delete` command should perform cleanup actions to ensure proper resource lifecycle management.","message":"By default, `local.Command` and `remote.Command` resources do not perform any 'delete' actions. If a command creates external resources, those resources will persist even if the Pulumi stack is destroyed or the command resource is removed, leading to unmanaged resources or cloud waste.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `pulumi.Output.secret()` to wrap any command outputs that contain sensitive information before exporting them or passing them to other resources. For example, `pulumi.export(\"sensitive_output\", pulumi.Output.secret(my_command.stdout))`.","message":"Sensitive information output by commands (e.g., passwords, tokens) will appear in Pulumi logs unless explicitly marked as sensitive. This can pose a security risk.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the official Pulumi upgrade guides and the provider's specific release notes before performing major version upgrades. Test your Pulumi programs thoroughly in a non-production environment.","message":"Upgrading to new major versions (e.g., from 1.x to 2.x) of the `pulumi-command` provider or the core Pulumi SDK can introduce breaking changes in resource properties, behavior, or required arguments. Always review release notes carefully.","severity":"breaking","affected_versions":"Any major version upgrade (e.g., 1.x -> 2.x)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}