Made ID optional, implemented state tracking #276
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.
Summary of Fixes in dnacenter/resource_global_credential_v2.go
The main issue was a critical bug in the Create function (lines 777-778) that caused the "Provider produced inconsistent result after apply" error.
Root Cause:
The provider was creating credentials successfully in DNA Center but failing to track them in Terraform state due to an empty resource ID.
Key Fixes Applied:
Proper Resource ID Management:
Now uses the task ID from DNA Center as the resource identifier
Falls back to timestamp-based ID if no task ID is available
State Population After Creation:
Immediately reads back credentials from DNA Center after creation
Populates Terraform state with the actual credential data
Better Error Handling:
Properly checks task completion status
Reports detailed failure reasons from DNA Center
Impact:
✓ Eliminates "Root object was present, but now absent" errors
✓ Maintains proper state tracking between Terraform runs
✓ Ensures resource consistency between Terraform and DNA Center
The fix ensures that created credentials are properly tracked and managed by Terraform, preventing state drift and enabling reliable resource management.