Closed polkx closed 1 month ago
Thank you for the report, I confirm we lack this method currently.
The workaround in this case is to explicitly create a provider like in this example.
@lbialy we need to find a good API design, because I'd like to avoid the problems other SDKs have with having both provider
and providers
. It is especially relevant here, because multiple providers are present in components, like eks
.
From TS API:
/**
* An optional provider to use for this resource's CRUD operations. If no provider is supplied,
* the default provider for the resource's package will be used. The default provider is pulled
* from the parent's provider bag (see also ComponentResourceOptions.providers).
*
* If this is a [ComponentResourceOptions] do not provide both [provider] and [providers]
*/
provider?: ProviderResource;
/**
* An optional set of providers to use for child resources. Either keyed by package name (e.g.
* "aws"), or just provided as an array. In the latter case, the package name will be retrieved
* from the provider itself.
*
* Note: only a list should be used. Mapping keys are not respected.
*/
providers?: Record<string, ProviderResource> | ProviderResource[];
Relevant documentation and code:
First of all, is cluster.provider a field on the resource or a core method exposing provider used to deploy this particular resource? I assume the latter and that in other implementations it's just a method inherited from Resource, right? If so, it should be trivial to add it in core. All it has to do is to reach to the guts of context and fetch the provider from the state. The issue is - there's a probability that field provider
exists somewhere so I guess we should do this as an extension method, which won't cause conflicts.
@pawelprazak your opinion here?
It's tricky IMO to provide sensible semantics here, because:
This has some consequences that are less than ideal:
Resource.provider
and also populate all providers
as wellMore context here: https://github.com/pulumi/pulumi/issues/8796
I believe Scala has strong enough type system to handle this gracefully, but I'm yet to find an elegant solution.
Alternatively, maybe the upstream implementation is good-enough and I'm overthinking this. A naive implementation would use those signatures:
def providers: NonEmptyString => Map[String, ProviderResource]
def provider: Optional[ProviderResource]
I'm curious what would StackResource return, I assume a None
You're thinking in terms of inheritance. We are free to ditch inheritance whenever we want to! This. is. Scala!
We almost never upcast to Resource
supertype so the easiest way to get this is to just use extension methods and the design is kinda trivial:
extension (cr: CustomResource) // this also handles ProviderResources but for them it's probably nonsensical
def provider: Output[ProviderResource] = ???
extension (cb: ComponentResource)
def providers: Output[Map[String, ProviderResource]] = ???
extension (cb: RemoteComponentResource)
def providers: Output[Map[String, ProviderResource]] = ???
fixed with #505 @polkx can you verify it works like you'd expect via just clean-all publish-local-all
with 0.4.0-SNAPSHOT version of core?
When I ask pulumi AI "aws eks hello world” I get: https://www.pulumi.com/ai/conversations/6ff221c6-9b0b-49be-8233-1afaf3e7fea7
I want to use
in Besom. Like below:
But class besom.api.eks.Cluster don't have a provider method.