terraform-provider-sumologic
terraform-provider-sumologic copied to clipboard
Fix use_versioned_api default value discrepancy
The current TF provider version has a bug where any new AWS sources (except S3 Source) when created, are using use_versioned_api as false despite having a default value of true.
This PR fixes that by:
- restrict setting the
useVersionedApionly when content_type isAwsS3Bucketelse always set it totrueinternally via code. - modifying the existing custom
diffSuppressFuncto not suppress the diff when thecontent_type != AwsS3Bucketand the current value ofuse_versioned_apiis set tofalseso that post the TF provider upgrade, all the sources that are using incorrect values of theuse_versioned_apiparameter can be updated and set totrue.
Testing Performed:
- [X] Verified creating S3 sources with
use_versioned_apiastrue,false, and null(missing field). - [X] Verified creating other S3 sources(other than
AwsS3Bucket) withuse_versioned_apiastrue,false, and null(missing field) and sources are always created with valuetrueas expected. - [X] Verified that post provider upgrade, the sources with incorrect values will be fixed.
what caused the bug exactly? not sure if I'm getting that information from the PR description
what caused the bug exactly? not sure if I'm getting that information from the PR description
not sure exactly but seems related to tf not being able to identify correctly when the parameter is not present and setting it to false.
let's spend some more time on the real root cause before putting in bandage fixes
@dagould found an old issue that shows that the default value is ignored when used with DiffSuppressFunc https://github.com/hashicorp/terraform-plugin-sdk/issues/70
so what's the proper fix?
From standup discussion it sounds like there is no proper fix since this is still an issue present in TF today, and we can only work around it. It would be nice if that was made more clear in your previous comment :)
I think we should update this doc if we are now restricting the value from being set to false for content types other than
AwsS3Buckethttps://registry.terraform.io/providers/SumoLogic/sumologic/latest/docs/resources/s3_source#use_versioned_api But on the other hand, we don't have this restriction on the backend, so I'm wondering if it's really a good idea to restrict it only in TF
I don't think we should update the docs as its only mentioned in s3 source documentation and not others and for s3 source we have no change in behavior.
we also don't mention it for other aws sources in sumologic documentation, but we don't block users from creating the source with this field in the backend if user sets it in the API
Probably add another test to see if there is any unexpected diff after reapplying the plan. I feel like the DiffSuppressFunc is buggy when I am doing testing for azure log source.
Updated the description with respect to the latest commit.