Is there a standard way to accomplish this pattern...
# dotnet
c
Is there a standard way to accomplish this pattern without running afoul of refreshes and drift issues?
Copy code
var myGenericSecret = new Vault.Generic.Endpoint( name, new Vault.Generic.EndpointArgs {
    Path = args.Path,
    DataJson = args.Data,
} );

var secretData = myGenericSecret.Path.Apply( p => Vault.Generic.GetSecret.InvokeAsync( new Vault.Generic.GetSecretArgs {
    Path = p,
} ) );

// generate outputs based on returned secretData
The original issue is that the Vault.Generic.Endpoint resource doesn't output the server-side result of the creation. Trying to supplement that by following it up with a GetSecret has been a dead end. If the endpoint doesn't exist for whatever reason, but pulumi thinks it does, pulumi still tries to execute the invoke, resulting in an error. Apparently making the invoke dependent on the output Path doesn't tie it closely enough to the lifecycle of the Endpoint resource for Path to be "unknown" in cases where the endpoint gets refreshed and is deleted. This is an example using Vault but it's a more general pattern of "create resource -> immediately fetch data about that resource" where I want the data and its "known-ness" to be explicitly tied to its associated resource. EDIT: This has been resolved, the issue was that the Endpoint itself was returning the wrong error code when the resource didn't exist. I was thrown off because the URL it was calling was identical to the GetSecret call I was attempting to (not) make.
I've futzed around with using OutputUtilities.CreateUnknown but that seems like too much black magic to reach for at this point
Maybe this is also a limitation in the pulumi vault provider; I thought using the Path output was a safe bet, but maybe that's simply copying the path from the input and not filtering it through the creation of the resource first.
e
I think if you depend on
myGenericSecret.Id
that will only ever be set on real updates, never on preview.
c
that's gtk and I was suspecting that. I think in this case the issue is actually on the vault plugin's side. it's returning 400s instead of 404s when the item doesn't exist
I was convinced it was the GetSecret call that was causing the issue because it was logging the same path but I'm confident now it's actually the Endpoint itself calling the url internally that was erroring
I didn't confirm it in the source but it seems safe to assume that terraform's vault provider (and by extension pulumi) determines existence based on status codes
happy to announce that updating the plugin to return 404s fixed the issue
🙌 1