What is the recommended way to run a piece of code...
# dotnet
w
What is the recommended way to run a piece of code after a resource has been provisioned? Is it to do
Apply
on a
Name
for example and then run some kind there?
s
What does the code do?
The provisioner examples might be relevant
w
I’ll check the calendar example when on computer, thanks. My plan is to create some sql db accounts when the db has been provisioned.
I have no clue how "provisioner example" turned into "calendar example"... Anyhow, is there a more lightweight approach to run something every time you do
pulumi up
after some resources have been provisioned. The provisioners example is heavier than expected and is also based on one resource dependency as I see it. I can definitely work my way around it, but I was thinking it might be an easier way?
I guess you were referring to this example @stocky-spoon-28903 https://github.com/pulumi/examples/blob/master/azure-ts-vm-provisioners/provisioners/provisioner.ts, looks like
Pulumi.Dynamic.Resource
doesn't exist for .NET yet though.
Since dynamic providers, https://www.pulumi.com/docs/intro/concepts/programming-model/#dynamicproviders, isn't available in .NET I'm on the search for a workaround. Any pointers?
s
Which DB is it?
w
Azure sql this time.
s
Is that SQL Server?
The best way to do this is to fit it into resource models - Postgres has a provider for example
w
I definitely agree, I just don't know how to do it for SQL Server. I would love to have something like a
SQL.Login
and
SQL.User
resource, but not sure how I would go about creating such a resource. Using a dynamic provider would make such a thing easy though.
my workaround at the moment is to solve it with db migration, but it is a little bit "hacky" because I sort of need to do two migration steps. One step to create login in master database and then one towards the actual database to create user and tables in that database.
s
w
Really appreciate your answers @stocky-spoon-28903! Not sure how I would go from that terraform provider to pulumi though. Also, not sure I want to base a pulumi provider on something that was made as an experiment two years ago. As of now I think I'll just have to live with my workaround.
s
You should talk to @broad-dog-22463 about this one!
👍 1
For users etc there’s probably something better than can be done
w
I definitely agree @stocky-spoon-28903, users (or logins as it is called in MSSQL) would ideally be created from pulumi. @broad-dog-22463, do you have any suggestion on this? I do have a workaround as mentioned so not critical at all but it would be a smoother experience working with SQL Server.