hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
42.79k stars 9.57k forks source link

Implement resource discovery functionality similar to OCI Provider #34854

Open oeresundsgruppen opened 8 months ago

oeresundsgruppen commented 8 months ago

Terraform Version

1.7.5

Use Cases

export existing configuration, instead of running provider exe

Attempted Solutions

provider exe can do this also, but maybe just have export option on terraform itself

Proposal

have export option on terraform itself

References

edit by @crw: The key summary of what the OCI provider is doing, from their documentation:

The Oracle Cloud Infrastructure (OCI) Terraform provider’s resource discovery feature uses HashiCorp’s terraform-exec to import the discovered OCI resources into Terraform configuration and state files.

apparentlymart commented 8 months ago

Hi @oeresundsgruppen!

I'm not sure what you mean by "export". Can you say more about what end goal/result you'd like to achieve? For the moment, let's focus on what this would allow you to do that you can't to today, rather than how/where it might be implemented.

Thanks!

oeresundsgruppen commented 8 months ago

well instead of running terraform-provider-oci_v5.33.0.exe -command=export, could have terraform export somefile.tf, and same for other providers

apparentlymart commented 8 months ago

Hi @oeresundsgruppen,

I don't know what terraform-provider-oci_v5.33.0.exe -command=export does. Can you give a full example?

Thanks

oeresundsgruppen commented 8 months ago

it just generates a TF file for the current config, and this can then be modified and then plan/apply to update...

apparentlymart commented 8 months ago

Hi @oeresundsgruppen,

I'm afraid I still don't really understand. I assume you mean something different by "the current config" than I am assuming, because for me "the config" already is a set of .tf files.

It really would help if you could show a full example of how you are running that command, concretely what it is producing, and what you are then doing with that result. It's tough to evaluate an enhancement request to incorporate some other tool's functionality into Terraform without knowing anything about what that tool does, how it works, and why it's useful.

oeresundsgruppen commented 8 months ago

terraform-provider-oci_v5.33.0.exe is used by terraform, but terraform itself does not have a way to export current actual config to tf file ?

oeresundsgruppen commented 8 months ago

kind of terraformer via terraform -export, but should be possible via the providers...

crw commented 8 months ago

Hi @oeresundsgruppen, thanks for this feature request! After much internal deliberation, the team believes you must be referring to this feature of the Oracle provider: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformresourcediscovery_topic-Using.htm. If this is incorrect, please let us know.

If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

oeresundsgruppen commented 7 months ago

yes, would be nice to have this directly in terraform