crossplane / terrajet

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

Make sure we are able to remove schema fields that are represented as different types #46

Closed muvaf closed 2 years ago

muvaf commented 3 years ago

What problem are you facing?

There are some APIs that allow you to manage the same object in two different APIs, for example you can manage NodeGroup through its API but also in an array under Cluster object. Per our Managed Resources API Design, we make the decision that in such cases, we'd choose to represent the resource only in one way and that would be a separate resource.

It seems like Terraform community also tries to follow this pattern but there are cases where they didn't do that in the past and now they can't change the interface. So, what they do for such resources is to show a warning, encouraging to use the separate API.

How could Terrajet help solve your problem?

Since we don't have a strong contract yet, we can omit those fields from schema before generation, i.e. remove nodeGroups field from cluster object. We can do that easily by manipulating the TF schema we give to CRD generator but we need to make sure it works well across the board by testing it manually and adding the instructions to the guide that is to be written.

muvaf commented 2 years ago

cc @ulucinar I think we need to be able to do this in order to make some Azure resources we discussed more XRM-compliant. Essentially, a config interface that will say move subnets field from spec of VirtualNetwork to status

muvaf commented 2 years ago

With https://github.com/crossplane-contrib/terrajet/pull/128 we now have access to TF schema in config object so we can do this operation.