Is there a way to handle a tf provider that calls ...
# contribute
b
Is there a way to handle a tf provider that calls a sub provider passing it command line args? The acme plugin I've been working on started doing that a few months ago. So going through the tf boiler plate works but the plugin blows up because it tries to pass the command line arg
-dnsplugin
to the pulumi plugin 🙂
image.png
l
Hello @bored-activity-40468, I want to inform you I brought this to the attention of the team working on the terraform bridge.
e
Greetings! I can't quite tell what's happening without looking at more of the code you're running. But I'm guessing you are trying to extend the command-line arguments with an extra argument and the framework is making it difficult.
Here https://github.com/pulumi/pulumi-terraform-bridge/blob/master/pkg/tfbridge/main.go#L31 Main assumes that it controls all the cmd-line flags
What you could try is env vars (should definitely work), or inlining Main into your program to all Serve instead of main, and reworking the command line parsing to add more flags. Would that work?
b
@enough-garden-22763 Thanks, I'll look at that. I think this comment in the terraform provider explains what's happening. https://github.com/vancluever/terraform-provider-acme/blob/718a3d18eb47b8c32af4f6e60d99505605eff008/acme/dnsplugin/client.go#L16
provider start -> call vendor dnsplugin -> vendor dnsplugin calls provider passing -dnsplugin letting it know its done.
e
Ah so it assumes os.Executable() "self" is a Terraform Plugin but it's now a Pulumi plugin. Oof.
b
yeah, exactly
I'm not super fluent in go, working on that but it seems like the terraform provider would need modified or a way for the plugin to pass thru args it receives outside of anything it expects, but not sure 🙂
e
So chatting with @limited-rainbow-51650 here this is a fun situation but perhaps you could do this. In the Pulumi plugin you either inline https://github.com/pulumi/pulumi-terraform-bridge/blob/master/pkg/tfbridge/main.go#L31 and rewrite arg handling or detect -dnsplugin arg before calling Main. If called with -dnsplugin arg, dispatch to a completely different main implementation doing what terraform-provider-acme was doing (no bridging).
l
e
Then you'd have Pulumi start the bridged provider process, and when that process spawns sub-processes the sub-processes behave exactly like terraform-provider-acme subprocesses which is probably what the thing expects. It sounds a bit tricky but it may work out.
b
That makes sense, I'll give it a go and let you know, thanks for the info and looking.