fix: check state for ibm_tg_connection_action correctly #4446
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.
This PR fixes a bug in ibm_tg_connection action. ibm_tg_connection_action was failing when the ibm_tg_connection involved was not created yet but worked for existing connections.
The bug was in a customdiff implementation that validates/checks for changes in the connection_action resource block. An action on a transit gateway can only be performed once. Once submitted, the cross account connection is either approved or rejected. This presented problems if the resource block changed, because the terraform state would delete but the backend would throw errors, and the terraform state would be out of sync. This background explains why a customdiff was needed.
A bug in connection action's customdiff was in how we are checking for action changes. Fixes were made so that:
Community Note
Relates OR Closes #4445
Output from acceptance testing:
Note: The terraform acceptance test framework does not support multiple providers configs with differing api keys. We can not use the acceptance tests for this feature because it needs two accounts/apikeys.
Manual tests
Create new connection and action
Expect failure when changing action on existing connection
Create new connection and reuse action resource block
Create new connection and change action in resused resource block