pulumi / pulumi

Pulumi - Infrastructure as Code in any programming language 🚀
https://www.pulumi.com
Apache License 2.0
21.59k stars 1.11k forks source link

Consider passing component resource properties to the engine #10533

Open justinvp opened 2 years ago

justinvp commented 2 years ago

A long time ago, a decision was made to not pass component resource properties to the engine: https://github.com/pulumi/pulumi/pull/2296 (more details: https://github.com/pulumi/pulumi/pull/2296#issuecomment-447709691).

However, this prevents component resource properties from being available from policies (and other analyzers), from unit test mocks, from display in the Pulumi Service, etc.

We should reconsider this behavior as there are certainly valid reasons why someone would want to inspect or test a component’s properties.

References

justinvp commented 2 years ago

Note that we may not be able to blanket turn back on passing input args for components. We have components in AWSX that stuff extra things (like resource options) in the args to make them available from the component’s initialize method, and Cyrus’s comment at https://github.com/pulumi/pulumi/pull/2296#issuecomment-447709691 leads me to believe there may be other things in our first-party component inputs that can cause issues (i.e. cycles). So there is some design work needed here to think through how we can enable this in a way that doesn’t break existing usage.

EronWright commented 2 months ago

Once we have the inputs in state, could we also pass them to Construct as olds? For example, this would enable the Chart v4 resource to reject changes to the resourcePrefix property.

lukehoban commented 2 months ago

A couple others scenarios this would enable:

  1. Pulumi Insights / Resource Search over component input/outputs
  2. Pulumi AI ability to suggest organization-specific patterns for using org-specific components/libraries
Frassle commented 2 months ago

Once we have the inputs in state, could we also pass them to Construct as olds?

Not easily. Construct is called from a different part of the system to the part that knows about old state

t0yv0 commented 3 weeks ago

We were looking here recently for the use case of collecting stats on the distribution of input parameter values for component resources to make informed decisions about deprecation and such (provided EULA permits this use). Could be very interesting to have this data in the state, and if not then perhaps in the engine logs (--event-logs option). Currently not available there either.