Search code examples
pulumi

How to get activity details for past updates on Pulumi, using Pulumi CLI?


If I go to app.pulumi.com, I can see in the browser the details for Update #903, for instance. It shows a summary: qty of new, modified and deleted resources. And I can also see the details, the specific resources that were created, modified, or deleted.

How can I get the same information using Pulumi CLI?


Solution

  • To the best of my knowledge, there isn't a way to get the data you're looking for with a CLI command, but you can get the data -- at least the raw data -- with the Pulumi Service REST API: https://www.pulumi.com/docs/reference/service-rest-api

    For example, assuming you've got curl, jq, and a Pulumi access token, you could do something like this (excuse my amateur Bash), which takes the update ID and calls another API to fetch the list of raw engine events associated with the update:

    get_update_id() {
        curl -s \
            -H "Accept: application/vnd.pulumi+8" \
            -H "Content-Type: application/json" \
            -H "Authorization: token $PULUMI_ACCESS_TOKEN" \
            "https://api.pulumi.com/api/stacks/$1/$2/$3/updates/$4" | jq -r .updateID
    }
    
    get_update_events() {
        curl -s \
            -H "Accept: application/vnd.pulumi+8" \
            -H "Content-Type: application/json" \
            -H "Authorization: token $PULUMI_ACCESS_TOKEN" \
            "https://api.pulumi.com/api/stacks/$1/$2/$3/update/$(get_update_id $1 $2 $3 $4)/events" | jq 
    }
    

    Then to use it:

    $ get_update_events orgname projectname stackname 1
    

    But be warned! The events API returns a lot of data, so expect to spend a little time figuring out what you're looking at. It should be all there, though. (The CLI and the console understand these events natively, but unfortunately the REST API doesn't yet expose it in a way that's as tidy as you'd probably like.)

    Hope that helps!