Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tailscale: do not show diffs when field names change (#274)
tailscale_acl resource currently expects users to provide intended policy content as a serialized JSON string. This JSON payload is not actually used directly in the API call to Tailscale - instead, it's deserialized, validated and serialized again by the `tailsacle-client-go` API library. Since JSON deserialization in Go matches field names in a case insentive way, as a result of this re-serialization, spelling of policy field names will be changed from whatever user specified, to the one configured in the JSON schema of the API client. For example, `ACLs` might change to `acls`. Tailscale API will accept field names in a case-insensitive way as well, and will store the payload verbatim. However during a next change, Terraform will fetch policy content from Tailscale API, and will show a diff, indicating that field names got changed. To avoid such spurious diffs, users currently need to use field names exactly as they are specified in the API client schema, just to satisfy Terraform. To handle this better, if we have ACL content in Terraform state, we check whether it's equivalent to the ACL fetched via API. If it is, we do not replace local state with the policy fetched from the API. As a result, local changed are always diffed against their previous version specified by the user (rather than against re-serialized payload returned from the API), and no spurious diffs are shown. Fixes #226
- Loading branch information