-
Notifications
You must be signed in to change notification settings - Fork 16
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
volumes: make Terraform import work #34
Conversation
Observation for shared-vpcs: |
@lonico thank you for the input above. Our actual problem it, that ID is not guaranteed to be unique over all regions. The import command required a unique ID. So how would a unique ID look like? It is actually an (ID, region) tuple. Maybe we should simply require the user to specify both, e.g by requiring an ID in "CVSID:region_name" format. We could parse the components and don't need to guess the users intention. |
@okrause I like your idea about "CVSID:region_name". And we could support both format, if we assume that ":" cannot show in CSVID or region_name. |
@lonico Great proposal, like it a lot. It maintains user convenience and terraform import usage consistency, while proving a solution for this super rare corner case. Will update the PR over x-mas. Have a wonderful holiday. |
- getAllVolumes is a helper function which returns all volumes in the project as a slice - filterAllVolumes will apply a filter function to the list of all volumes and returns a slice of matching volumes - getVolumeByID now uses filterAllVolumes in case region is not set (will happen for terraform import)
- getAllVolumes now takes region argument and is renamed to getVolumes - refactored getVolumeByRegion and commented it out, since it is not used
support ID = <volumeID> and ID = <volumeID>:<region> for terraform import
Hohohoho, here are coming the x-mas eve changes to terraform import. A user can continue to import using the standard way ( I also did some refactoring to reduce redundant code. Feedback welcome |
When importing volumes on a shared VPC, we have to repopulate attribute shared_vpc_project_number
Turns out API ((sometimes?)also returns long network path without shared VPC. Make projectID detection more stable.
This PR is a possible solution for volume import (see issue #33 ).
It implements approach number 1. It is the most simply solution and should work well, but will fail for the very unlikely corner case that more than one volume hold a volume with the requested volume UUID.
A proper importer which can also handle cases where multiple volumes with the same ID are found would be the cleaner solution.
This is how to use it:
terraform import netapp-gcp_volume.myvolume 6462b343-262c-e785-dc6c-ca5fcfc7e185
terraform show -no-color > volume.tf
to create the resource definition (overwriting the prior empty definition).id
line in volume.tfterraform plan
. If everything went fine, it should run without proposing changes.Happy to discuss.