Hi, I've decided to use Pulumi to set up my Snowfl...
# general
s
Hi, I've decided to use Pulumi to set up my Snowflake resources and
pulumi-snowflake
seems to be great for this. My problem currently is that I'm not able to use different roles during execution. For example, I use SYSADMIN to create a database and I want to use SECURITYADMIN to create a new role. In the config file, I set up
snowflake:role
to SYSADMIN and I try to change to
os.environ["SNOWFLAKE_ROLE"] = "SECURITYADMIN"
but it doesn't seem to be picked up.
1
p
Hey Roni, this is likely an either or situation. Usually with pulumi/terraform it goes through a list of options for where a config option can be set, and once it finds a config option it stops looking
It sounds like what you want is a 2nd provider
s
Well, I may need a few roles throughout the execution...
Is it possible maybe to change a parameter in the config during execution?
usually when setting up a Snowflake environment, you want to use various roles for the different assets
p
Yep. So the right way to do this is to create multiple providers
If you haven't done this before, most code uses a default provider
What you're going to want to do is for each role you'll want to create a different provider
So for example in pseudocode
Copy code
sysadmin_provider = snowflake.Provider("sysadmin",role="SYSADMIN")
securityadmin_provider = snowflake.Provider("securityadmin", role="SECURITYADMIN")

foo_resource = snowflake.foo(arg=bar, pulumi.ResourceOptions(provider=securityadmin_provider)
s
nice! this is exactly what I was looking for!
thanks!
I'm getting another error that I can't seem to pass through it...
Copy code
File "/Users/roni/.conda/envs/venv/lib/python3.10/site-packages/pulumi_snowflake/schema.py", line 358, in _internal_init
        raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
    TypeError: __props__ is only valid when passed in combination with a valid opts.id to get an existing resource
I provide the provider as follows to the Schema object:
Copy code
opts=ResourceOptions(id="blah", provider=sysadmin_provider)
I will try to debug later if it's not obvious
p
I don't think you need the id field
s
I added the
id
after I got the error... so the
id
didn't help
Copy code
snowflake.Schema(name.upper(),
                            comment=comment,
name=name.upper(),
data_retention_days=30,
database=db_name,
is_managed=False,
is_transient=False,
opts=ResourceOptions(provider=provider))
p
I'll take a look in a bit. I'm on my phone which is not conducive to reading code on github
s
thank you sir! I'm also trying to uncover the issue on my side!
p
I'd suggest skimming the pulumi code for the snowflake provider.
s
I think it was something with my repo build... it seems to work now... thanks!