-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix webhook management issue #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
hookID := d.Get("id").(string) | ||
|
||
fmt.Println(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gabrieldagama any idea why this print statement was here in the upstream branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea... maybe some debug? not sure!
Not a review but just an observation ... I hate single character variable names 😅 😆 |
There were two issue with initial implementation for this provider:
1 - On the resource level,
client_id
,store_hash
,created_at
andupdated_at
fields were not persisting on the TF state, meaning that just after creating the resource if you run aterraform plan
terraform would return saying that those fields were changed outside terraform management, which wasn't the case. To fix this we basically removed those fields from state as there was no need for them, we just leftclient_id
but that is being managed differently now to fix the second issue.2 - The second issue was related to updating BigCommerce credentials on the provider, if the project is already live and this change is done, terraform will create new webhooks for the new credentials and won't delete the old ones, therefore leading into our application receiving double webhooks requests. And if the credentials are deleted from BigCommerce we will need to open a BigCommerce suppport request for deleting those webhooks.
To fix this problem we had to move the bigcommerce
access_token
andclient_id
properties from the provider to the resource level, meaning that each webhook will declare these properties. I'm aware this change is not ideal as this is suppose to be a general provider for BigCommerce however I could not find another approach for dealing with this problem because terraform does not track state change from the provider perspective, so whenever changes are done on the provider we don't have access to previous data therefore not able to delete old webhooks.A possible approach was to add properties
prev_access_token
andprev_client_id
to the provider and track this state however this didn't fix the problem because terraform would still create the new ones and we would need to hack terraform resource structure in order for this approach to work, I believe it will increase complexity even further.The approach on this pull requests would mean that the declaration of a provider is changed to:
And the declaration of a webhook resource is now:
It may make sense to rename this provider to something more webhook specifically. This pull request also adds acceptance tests to the repository.