This message was deleted.
# general
s
This message was deleted.
b
Sounds like a good use for our
ComponentResource
model: https://www.pulumi.com/docs/intro/concepts/programming-model/#authoring-a-new-component Don't forget that you can share these (and a lot of the code you write) in the same way you'd share other such libraries: npm, nuget, pip etc
c
Thanks Piers.. would the general strategy be to create a new 'stack' for each environment then? and effectively put the 'reusable' template stuff into a component?
b
@cuddly-smartphone-15267 Yeah a "stack" is just a representation of the state and config for a collection of resources so a stack per env or even a stack per developer is the general use here
I have seen people using a stack per customer tenant as well but YMMV
c
ok, thanks Paul... makes sense, cheers. would we need a separate little 'program' per stack? in .net , it generally goes
Copy code
class Program
{
    static Task<int> Main() => Deployment.RunAsync<MyStack>();
}
b
nope - MyStack is a generic class used so dev1 stack will use MyStack, dev2 stack will use MyStack
MyStack probably should be named MyProject
c
So let’s say we renamed MyStack to MyProject. how would dev1 stack use MyProject? Sorry if it’s a dumb question, just trying to join the dots. Would it inherit from it? Would it new it up?
b
So let’s say your application creates a resource group, a storage account and a storage container
That’s a project
A stack is when you deploy that project - let’s say to a dev environment
So the stack is just the actual state of the resources (+ any config)
It’s not the code itself
Stacks are the deployed resources on top of a project
Does that make it a bit more clear?
c
Hmm. Kind of. So you’re saying that the project is like the blueprint. And the stack is like the result of constructing based on that blueprint. So I guess I’m wondering how to organise the code so that I can construct that blueprint several times (with slightly different configurations) within one account.
b
You don’t need anything special for that
Create your code then <for each name in a loop> Pulumi stack init
That will create you all the stacks you need on top of the project and then you can add config and run Pulumi up in each of those stacks independently
A project (where your code resources live) can have many stacks (pointing to where the resources have been deployed) Each stack can take its own credentials and config and the base code will be deployed as the stack dictates
c
Thanks very much Paul for taking the time to explain to me. I don’t suppose there are any examples I could refer to?
b
There’s a small intro as code workshop you can step through
Ping me if you need anything - happy to help!