Thread
#general
    m

    millions-journalist-34868

    7 months ago
    I have starting testing the new Command package in preview and I was wondering how I could debug it. My script seems not to work inside the Command resource and I have no way to debug it as I can't get any error message. Does anyone know how to get error messages from the Command package ?
    b

    bored-table-20691

    7 months ago
    It’s pretty painful. The only way I’ve found out is to basically make it succeed (i.e. eat up any exceptions it may throw, print them out and exit successfully) and then print out the stdout/stderr you got back.
    l

    little-cartoon-10569

    7 months ago
    Would you be able to hook your remote code into whichever channel you're using for
    pulumi log
    ?
    CloudWatch or whatever...
    But either way, the onus is on you. The code runs remotely, so the logs are generated remotely...
    b

    bored-table-20691

    7 months ago
    I don’t think any output from stdout/stderr of the executed Command is currently outputted by Pulumi, and definitely not on failure.
    l

    little-cartoon-10569

    7 months ago
    No, the output would be from the command itself. You'd have to capture it and send it to whatever Pulumi uses for reading logs in your preferred cloud provider.
    It would be a useful ComponentResource or even feature request.. to add a CloudWatch (or whatever) log group automatically and add all output/error output to it. Unfortunately @pulumi/cloud doesn't support logging yet, that would be an easy way to create a cross-platform solution for this.
    b

    bored-table-20691

    7 months ago
    This seems like a pretty extreme way to see the stdout and stderr of a locally run command (in the case of local.Command)
    l

    little-cartoon-10569

    7 months ago
    Yes, it wouldn't be appropriate there. I haven't used it to run local commands before, the use case didn't occur to me.
    The example on the API doc page suggests you can just export the command's stdout and stderr properties.. does this fail when the command fails? Probably worth reporting an issue. It should work (and
    <http://pulumi.log.info|pulumi.log.info>(command.stderr)
    should work too).
    b

    bored-table-20691

    7 months ago
    Yes it does. There's already an issue for this.
    When the command fails then the entire resource fails and you don't get a resource - just the err object which contains no info.