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.
What this PR does / why we need it:
Add support for Terraform imports to the Terraformer.
There are certain cases, primarily migration scenarios, which require to import existing resources into the Terraform state. See here for an example.
The imports can be defined in the
*.infra.tf-config
configmap via.data.imports
.This need to be look like this:
The resources will be imported in the order as they are specified. Only if all imports succeed the state will be persisted. After that the
*.infra.tf-config
configmap will be patched to remove.data.imports
as the imports are now part of the state.Special notes for your reviewer:
Here is an example to test the import behaviour based on the mentioned issues above. You need the
azurerm
provider with version>= 2.12.0
. You can use this image to test:dominickistner/terraformer:test-import-1
(test image contains a bash for debugging)Modify the configuration configmap with the following changes and apply the modified configmap.
You need to remove the
public_ip_address_ids
field from theazurerm_nat_gateway
resource and enable the twoazurerm_nat_gateway_public_ip_association
resources.Try to apply again. It should fail due to import error like that:
The
azurerm_nat_gateway_public_ip_association
resources should be now part of the state. Run import once more. There should be no diff.Apply once more. It should now succeed.
Finally destroy the created resources again.
Release note: