Add support to import machine configs v2 #1846
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
As we can import clusters it would be nice to have the ability to import machine configs v2 too.
Testing
I was able to generate import file of my machine config successfully like this:
❯ cat import.tf import { to = rancher2_machine_config_v2.nc_test id = "fleet-default/nc-test-pool1-zs2g8" } ❯ terraform plan -generate-config-out=generated.tf Found existing alias for "terraform plan". You should use: "tfp" Acquiring state lock. This may take a few moments... helm_release.rancher: Refreshing state... [id=rancher] rancher2_machine_config_v2.nc_test: Preparing import... [id=fleet-default/nc-test-pool1-zs2g8] rancher2_machine_config_v2.nc_test_pool1: Refreshing state... [id=fleet-default/nc-test-pool1-qnqw8] rancher2_cluster_v2.db-operations-sand: Refreshing state... [id=fleet-default/db-operations-sand] rancher2_cluster.local: Refreshing state... [id=local] rancher2_cluster_v2.test: Refreshing state... [id=fleet-default/test] rancher2_machine_config_v2.nc_test: Refreshing state... [id=fleet-default/nc-test-pool1-zs2g8] Planning failed. Terraform encountered an error while generating this plan. ╷ │ Warning: Config generation is experimental │ │ Generating configuration during import is currently experimental, and the generated configuration format may change in future versions. ╵ ╷ │ Error: "generate_name": required field is not set │ │ with rancher2_machine_config_v2.nc_test, │ on generated.tf line 1: │ (source code not available) │ ╵Generated TF file contains
generate_name=nullwhich must be corrected manually. That's not the deal-breaker as we see this behaviour during the import of others resources.