-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow dynamic querying of resources #83
Comments
Here is what I am thinking. All resources are given three new APIs (shown in TypeScript):
A few notes:
Finally, all of these can bottom out on two APIs in the provider layer:
Thanks to gRPC streams (over HTTP/2), we can get nice streaming behavior with |
Name for |
I've gone backwards and forwards on this one myself. The URN actually does show up in a number of places: it's in the state files, printed to the console, and, in fact, as of the output properties change it is accessible as the You are right that this is a foundational piece for dynamic linking. I don't know that this is all it'll ever be useful for, however. It's possible you'd want to use this as a slightly more stable ID than the physical provider ID, for example. There are many ways I could imagine it being used in practice. For now, I'll leave it out, since it's always easier to add later on. Best to tackle as part of #109. Good catch on Thanks for the feedback! |
This change implements the `get` function for resources. Per #83, this allows Lumi scripts to actually read from the target environment. For example, we can now look up a SecurityGroup from its ARN: let group = aws.ec2.SecurityGroup.get( "arn:aws:ec2:us-west-2:153052954103:security-group:sg-02150d79"); The returned object is a fully functional resource object. So, we can then link it up with an EC2 instance, for example, in the usual ways: let instance = new aws.ec2.Instance(..., { securityGroups: [ group ], }); This didn't require any changes to the RPC or provider model, since we already implement the Get function. There are a few loose ends; two are short term: 1) URNs are not rehydrated. 2) Query is not yet implemented. One is mid-term: 3) We probably want a URN-based lookup function. But we will likely wait until we tackle #109 before adding this. And one is long term (and subtle): 4) These amount to I/O and are not repeatable! A change in the target environment may cause a script to generate a different plan intermittently. Most likely we want to apply a different kind of deployment "policy" for such scripts. These are inching towards the scripting model of #121, which is an entirely different beast than the repeatable immutable infrastructure deployments. Finally, it is worth noting that with this, we have some of the fundamental underpinnings required to finally tackle "inference" (#142).
@bforsyth927 is carrying the query pieces forward from here. Reassigning and putting this in 0.4, since we won't have time to finish it this milestone. |
@bforsyth927 did a great prototype of this during the sprint. It is archived in the PR #289. I'm removing this from the sprint since productizing this will likely wait until a later date. |
Bringing this back, since we lost our ability to |
One question on this - and I'll open an issue in the In practice, we haven't needed this in a bunch of places because we have just been projecting Terraform AWS providers with raw string based properties instead of strongly typed properties. This means it's easy to just provide the string value of the I actually wonder whether we want to just go back to not trying to project strong types onto the raw projections. That will simplify a lot of these cases, and give us (and users) a lot more flexibility. It's not quite as pretty, but in practice as we've built larger things, this hasn't felt like a cost (and indeed has helped ensure we don't hit too many roadblocks). |
I will comment on the overlay part in the AWS repo, however, I still think want this capability, so that you can look up arbitrary property values from existing resources. This will also be a foundational capability that we use when enabling #109. That said, we found a way to work around this in the current customer scenario, so I'm going to punt this to 0.9. |
@hausdorff did some prototyping of |
We'll land the first part of this (querying against an existing stack's state, not live resources) in #2630. |
Opened #83 as a more up-to-date tracking item for the remaining piece of this. |
…Stack - change executors and remove sleep
…Stack - change executors and remove sleep
…Stack - change executors and remove sleep
…Stack - change executors and remove sleep
…Stack - change executors and remove sleep Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
…Stack - change executors and remove sleep Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
There may be circumstances in which we want to dynamically discover resources.
For example, when reverse engineering the LumiGL from an existing environment, we may have an object moniker and/or set of properties in hand, and want to discover a resource's ID, if any. There is no reason we couldn't support an API like the following on
ResourceProvider
, for examples:Going even further beyond that, we may eventually want a way in Lumi programs themselves to look up resources dynamically. For example, imagine our organization has set up an ECS cluster, and we simply want to plug into that. It would be reasonable to write code like this:
It's not clear what
"id"
we would use for this, but presumably the object moniker would be a great place to start. In that case, the hypotheticalResourceProvider.Find
API above would do the trick.It's possible we would want to support more sophisticated queries (eventually), however we need to be careful not to lead people down a bad path. For instance, hard-coding an ARN into a Lumi program would tie that program to a specific deployment, whereas the moniker is sufficiently "logical" that it wouldn't interfere with multi-instancing, etc.
The text was updated successfully, but these errors were encountered: