tailscale / terraform-provider-tailscale

Terraform provider for Tailscale
https://registry.terraform.io/providers/tailscale/tailscale
MIT License
255 stars 46 forks source link

tailscale: support ACL contents as HuJSON #332

Closed knyar closed 6 months ago

knyar commented 6 months ago

The acl argument of the tailscale_acl resource can now be a HuJSON string. Instead of unmarshalling acl into an ACL struct of the API client just to have the client serialize it into JSON again, policy content gets passed to the Tailscale API verbatim.

This allows users to define their policy as HuJSON strings, with comments being preserved. Since JSON is a subset of HuJSON, this is backwards compatible, so I am not adding a separate field for this as has been previously suggested in #227.

Validation is now performed by calling the Validate and test policy file API, which will help catch any semantic errors in the policy at terraform plan stage (for example, when a syntactically correct policy contains configuration that is not supported by the Tailnet's current pricing plan).

Finally, this will also allow users to use new fields in the policy without requiring a new release of the Terraform provider.

I've also added a new hujson field to the tailscale_acl data resource that shows current policy as a HuJSON string.

Fixes #331 Fixes #227