5 months ago
    hi, is there a way to get stack references during runtime, i.e., suppose I want to know the hostname of some instance produced by pulumi in downstream service code, could I reference the typical "infra" pulumi program somehow, and get that value? other example would be like the name of a secret that gets pulled in runtime. the secret is created via pulumi. then the secrets SDK makes a call to the service to actually get the value


    5 months ago
    If it's in the same project/stack, you must use the input value; you can't get values that will be created in the future.
    If it's in a different stack, then yes.
    Take as an example the secrets example. Rough flow:1) Your declarative code sets up a new Secret object in secretsmanager, which means that when the Pulumi engine runs, that value will be confirmed/created/updated in secretsmanager. 2) Later in your Pulumi program, you want to use that value. The Pulumi engine hasn't run yet (it runs after all your code is run, and it has fully built the resource tree from your code), so you can't query the value from secretsmanager: the value isn't there yet. The value is in your code though, since you have the code that puts the value in secretsmanager. So you get it from there, instead.