Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract project resources to terraform format #4553

Open
Kaylleur opened this issue Feb 27, 2025 · 1 comment · May be fixed by #3570
Open

extract project resources to terraform format #4553

Kaylleur opened this issue Feb 27, 2025 · 1 comment · May be fixed by #3570
Assignees
Labels
enhancement priority:medium Improvements that are not the main priority

Comments

@Kaylleur
Copy link

Kaylleur commented Feb 27, 2025

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.

@remyleone remyleone linked a pull request Feb 27, 2025 that will close this issue
@remyleone
Copy link
Member

Thanks a lot for the feedback, we already started with @Codelax with a draft of a similar features. New features coming in terraform might also help bring an easier integration.

@remyleone remyleone self-assigned this Feb 27, 2025
@remyleone remyleone added the priority:medium Improvements that are not the main priority label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement priority:medium Improvements that are not the main priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants