Is it possible to use two providers, in my case AzurermProvider and PanosProvider in one TerraformStack ? I can see an example here but how do I know how resources are tied to providers. I can create resource from PanosProvider but don’t see how it knows which provider to use
Yes, it is possible to use multiple providers just as that example shows.
Resources are actually defined by the providers, so they know internally which one to use.
Looking at that example, you can see that Instance
is imported from ./.gen/providers/aws
and Record
is imported from ./.gen/providers/dnsimple
.
If any resources have name conflicts, you’ll need to qualify which one you are using.
Appreciate ! I was also thinking what about using same provider twice … So for example two panos providers referring to two appliances with different hostname .
new PanosProvider(this, ‘panorama1’, {
hostname: “1.1.1.1”,
username: “admin”,
password: “secret”,
})
new PanosProvider(this, ‘panorama2’, {
hostname: “2.2.2.2”,
username: “admin”,
password: “secret”,
})
how will I assign resources to them ? I mean how I refer to provider explicitly when creating resource.
You might want to read through this issue.
It is possible to do that by using the alias
property when creating the provider and then setting the provider
property on the resource to the correct provider; however, if the resources created with each provider aren’t logically connected (or only very loosely), this may not be the best pattern to use.
I was able to successfully use Azure and AWS within the same stack - same file. Pretty awesome!
Thank you for sharing, I wouldn’t even think to try…or ask, very interesting