https://pulumi.com logo
Title
b

bored-activity-40468

05/09/2021, 5:29 PM
Is the Stack type still used if an InlineProgram is created? Looking at the code it doesn't seem to be. Does the InlineProgram become the roots stack?
b

bored-oyster-3147

05/10/2021, 1:15 PM
You can still use the stack type. The functionality is on the
PulumiFn
class. It is just another way of providing your pulumi program delegate. You could either: •
PulumiFn.Create<TStack>();
PulumiFn.Create(delegate);
It is the same functionality as before Automation API where you would either: •
Deployment.RunAsync<TStack>();
Deployment.RunAsync(delegate);
b

bored-activity-40468

05/10/2021, 2:28 PM
Thanks, yeah, I dug through the code. So, with an InlineProgram, when a resource is created the parent isn't auto-set like with a stack, which makes sense.
b

bored-oyster-3147

05/10/2021, 2:34 PM
no that isn't exactly true, there is always a root stack resource. If you aren't using a
TStack
type than internally Pulumi is just doing that for you. I can link you the code 1 sec
Here you can see that
Pulumi.Stack
has an internal constructor that takes in a delegate. And here you can see that if you provide a delegate instead of a
TStack
type than it is just using that internal constructor, so there is always a root
Pulumi.Stack
resource.
👍 1
In both cases,
TStack
and delegate programs, the following code:
var parent = type == Stack._rootPulumiStackTypeName
                ? null
                : (options.Parent ?? Deployment.InternalInstance.Stack);
parent
would be set by
Deployment.InternalInstance.Stack
It just ensures that
Pulumi.Stack
resource never has a parent
👍 1