Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Description
I would like to have a new command in the Scaleway CLI that allows exporting existing resources from a specified Scaleway project into a Terraform template. Additionally, it should generate the corresponding terraform import
statements, so we can easily bring existing resources into a Terraform-managed state without manually writing each resource definition and import command.
This feature would be especially helpful for teams migrating from a manual configuration or other tooling to Terraform, as it would significantly reduce the time and potential errors involved in translating existing infrastructure into Terraform code.
How I imagine scw could expose this functionality
A possible example command:
scw project export-terraform --project-id <PROJECT_ID> --output-file <FILE_NAME>
--project-id <PROJECT_ID>
: specifies the Scaleway project from which to extract the resources.
--output-file <FILE_NAME>
: specifies the path and file name where the generated Terraform code should be saved (e.g., main.tf).
The command could also generate an accompanying file (or additional output) containing the import commands, for instance:
terraform import scaleway_instance.server_id <resource_id>
and so on for each resource found in the project.
This way, a user can run something like:
scw project export-terraform --project-id <PROJECT_ID> --output-file main.tf
Inspect/update main.tf as needed.
Run the import commands generated by the CLI to populate their Terraform state.