Skip to content

Return error for non-existent resources when using terraformless export#560

Merged
magodo merged 2 commits intoAzure:mainfrom
magodo:tfclient_import_nil_state
Sep 4, 2024
Merged

Return error for non-existent resources when using terraformless export#560
magodo merged 2 commits intoAzure:mainfrom
magodo:tfclient_import_nil_state

Conversation

@magodo
Copy link
Collaborator

@magodo magodo commented Sep 4, 2024

Previously, when using terraformless export (i.e. -tfclient-plugin-path), if the resource/resource group to be exported doesn't exit, an empty HCL block will still be generated.

This PR adds additional check after the ReadResource RPC call, to raise error if the state read is nil. This logic exists in terraform (@internal/terraform/node_resource_import.go), that's why terraform export will correctly raise the error for non-existent resources.

@ziyeqf ziyeqf self-requested a review September 4, 2024 02:53
@magodo magodo merged commit ee37f13 into Azure:main Sep 4, 2024
@magodo magodo added the bug Something isn't working label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants