Skip to content

Conversation

@pnpdev10
Copy link

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.

resourceMap := make(map[string]string)  // Empty map!
d.SetId(joinResourceID(resourceMap))    // Results in empty/invalid 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant