Is there a way to check the version of Pulumi CLI ...
# general
a
Is there a way to check the version of Pulumi CLI at runtime?
w
This right here, sir! https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#version
import { version } from "@pulumi/pulumi";
a
But that will get me the version that's installed via npm, not the version of the Pulumi CLI. I guess it doesn't really matter in the end, the Pulumi CLI will simply call node and that's the version that I should care about. I think...
w
Oh, good point! Hmm, I’m curious how we would even do this. We could expose the CLI version via Automation API, but you’re trying to access it from the language SDK, so we might be best off with an gRPC call for that.
Just curious, why do you think you’re more interest in the node version than the CLI version? What’s the problem you’re trying to solve?
a
The whole story is that I'm trying to avoid being bit by https://github.com/pulumi/pulumi/issues/12964 again, which took me over a week to fix.
We're using Python, so what I usually do is increase the version in the
requirements.txt
file and then have a check at runtime to see if dependencies match. So far so good.
But then it got me thinking: what would actually happen if you're running the CLI version 3.67.0, but using a 3.68.0 SDK package? I now think that the SDK package is what matters in this case, not the Pulumi CLI version. If that's the case, then it's all good, I don't need to know the CLI version and there's no problem.
The CLI simply runs the application in whatever language/SDK you have, so unless there's a rare compatibility issue, it shouldn't really matter, right?
w
Ah, I hate to be the bearer of bad news, but the
--target
regressions are caused by issues in the engine, which is part of the CLI, so the CLI version is what you want to check. The CLI does a lot more than just run the user program, I'm afraid. Suppose you have a Node program that creates an AWS S3 bucket. First, the engine launches the Node program. The Node program tells the engine "I want an S3 bucket". The engine launches the AWS provider, which, like the Node program, is its own process with a gRPC server for communicating back and forth with the engine. Finally, the engine tells the AWS provider "give me an S3 bucket". I'm eliding some details (and additionally processes!) but that's the crux of it. The Node program isn't making calls to AWS's API itself; it just tells the engine (i.e. the CLI) what it wants. In the case of
--target
, the CLI is filtering out the requests from the Node program and only selecting the targeted one. This is also how other resource options, like
dependsOn
,
ignoreChanges
, and more are applied. The engine determines the order in which to create the resources, and whether they need to be created at all.
I'm sorry you were bit by the
--target
regression. I know it's no consolation for your lost time, but my teammate has been heads-down for the past month working to get
--target
in a better place. We conduct postmortems as a team within a week of each regression, so
--target
has been discussed many times this month!