Skip to content
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

Fixes PermaDiff Issue in google_storage_transfer_job.aws_s3_data_source.aws_access_key field #20849

Conversation

modular-magician
Copy link
Collaborator

Fixes permadiff issue in google_storage_transfer_job resource. Ticket: b/386174536

Cause: It appears that the issue is happening because of GetOkExists used to obtain value of aws_s3_data_source.aws_access_key in the flattener. GetOkExists checks for the presence of the value regardless of zero value of the field. So here, In this case, we are always getting zero value of the field aws_s3_data_source.aws_access_key which empty list, [], and true for it's existence even though it's not specified in the config.

Solution: We can use GetOk to obtain value of the field from the config. GetOk treats zero value as absent which is use case here like other TypeList field.

Alternative: Continue using GetOkExists and checking empty vs unset each time,

aws_access_key, exist := d.GetOkExists("transfer_spec.0.aws_s3_data_source.0.aws_access_key")
if !tpgresource.IsEmptyValue(reflect.ValueOf(aws_access_key)) && exist {
data["aws_access_key"] = flattenAwsAccessKeys(d)
}

As GetOkExists is deprecated, reference, and discouraged to use, I prefer GetOk and didn't see any problem with that as all the nested fields within aws_access_key are required. So there won't be a case of empty block(without any nested field specified) and we need to separate from unset nested fields.

Testing: Currently storagetransfer service lacks acceptance tests for third-party cloud providers so there is no way to add acceptance tests.

storagetransfer: fixed a permadiff with `transfer_spec.aws_s3_data_source.aws_access_key` in `google_storage_transfer_job`

Derived from GoogleCloudPlatform/magic-modules#12666

…rce.aws_access_key` field (hashicorp#12666)

[upstream:2b00b9bdf989b2ea8902acec8ee401d0d889da22]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician requested a review from a team as a code owner January 8, 2025 17:40
@modular-magician modular-magician merged commit 661ee26 into hashicorp:main Jan 8, 2025
4 checks passed
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