crossplane / terrajet

Generate Crossplane Providers from any Terraform Provider
https://crossplane.io
Apache License 2.0
290 stars 38 forks source link

Consider creating CRDs for data sources for observe-only cases #127

Closed turkenh closed 2 years ago

turkenh commented 2 years ago

What problem are you facing?

In addition to resources that allow managing cloud resources, Terraform providers also have data sources . Generating data source resources could solve the issue of observing external resources with Crossplane without actually managing them.

How could Terrajet help solve your problem?

By generating CRDs also for data sources.

stoehdoi commented 2 years ago

Supporting data resources in terrajet would be really helpful. That way, already existing resources that are managed by a different stack could be imported and referenced in other (managed) resources using the already exiting selectors (name/label).

I am actually having a use case where I would have to fetch a list of Route Tables (like with this terraform data resource) based on a set of tags so I can create additional routes. Not sure if that would work with the current implementation though as the route resources only takes a single route table id in the spec, not a list.

muvaf commented 2 years ago

We have a very similar feature request in core Crossplane covering all providers as @turkenh linked. In my opinion, we should solve this problem in Crossplane for all providers and then come back here to see how Terrajet can adapt. I have a hunch that we won't need a code change here and just let the generic managed reconciler know the resource is read-only so that it calls only Observe method of our ExternalClient implementation. But it could be the case that we decide to change the implementation to be backed by data_source instead of resource in case it's marked as read-only.

In fact, it feels too close to that original issue that I think we can close this one and track it there until we decide to implement the decision in Terrajet.