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

Support for ACL grants in acl policy #331

Closed
theexiile1305 opened this issue Feb 13, 2024 · 0 comments · Fixed by #332
Closed

Support for ACL grants in acl policy #331

theexiile1305 opened this issue Feb 13, 2024 · 0 comments · Fixed by #332
Labels
enhancement New feature or request

Comments

@theexiile1305
Copy link

Is your feature request related to a problem? Please describe.
It's apparently not possible to create acl grants aka the object grants object in the acl policy.

Describe the solution you'd like
A way to create the grants obejct in the tailscale_acl ressource.

Additional context
In the following example, terraform validate and terrraform plan return the error json: unknown field "grants". (This error may be caused by a new ACL function that is not yet supported by this terraform provider. If you are using a valid ACL field, please raise an issue (https://github.com/tailscale/terraform-provider-tailscale/issues/new/choose)

resource "tailscale_acl" "acl" {
  acl = jsonencode({
      grants : [{
        "src" : ["group:my-team"],
        "dst" : ["tag:k8s-operator"],
        "app" : {
          "tailscale.com/cap/kubernetes" : [{
            "impersonate" : {
              "groups" : ["system:fancy-users"],
            },
          }],
        },
        }
      ]
  })
@theexiile1305 theexiile1305 added the enhancement New feature or request label Feb 13, 2024
@theexiile1305 theexiile1305 changed the title Supportr for ACL grants in acl policy Support for ACL grants in acl policy Feb 13, 2024
knyar added a commit that referenced this issue Feb 14, 2024
The `acl` argument of the `tailscale_acl` resource can now be a HuJSON
string. Instead of unmarshalling it into an `ACL` message of the [API
client](https://github.com/tailscale/tailscale-client-go) 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](https://github.com/tailscale/tailscale/blob/main/api.md#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](https://tailscale.com/pricing)).

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

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
knyar added a commit that referenced this issue Feb 14, 2024
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](https://github.com/tailscale/tailscale-client-go) 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](https://github.com/tailscale/tailscale/blob/main/api.md#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](https://tailscale.com/pricing)).

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

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
knyar added a commit that referenced this issue Feb 14, 2024
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](https://github.com/tailscale/tailscale-client-go) 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](https://github.com/tailscale/tailscale/blob/main/api.md#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](https://tailscale.com/pricing)).

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

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
knyar added a commit that referenced this issue Feb 14, 2024
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](https://github.com/tailscale/tailscale-client-go) 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](https://github.com/tailscale/tailscale/blob/main/api.md#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](https://tailscale.com/pricing)).

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

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
knyar added a commit that referenced this issue Feb 15, 2024
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](https://github.com/tailscale/tailscale-client-go) 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](https://github.com/tailscale/tailscale/blob/main/api.md#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](https://tailscale.com/pricing)).

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

Signed-off-by: Anton Tolchanov <anton@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant