|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "grafana_cloud_access_policy_rotating_token Resource - terraform-provider-grafana" |
| 4 | +subcategory: "Cloud" |
| 5 | +description: |- |
| 6 | + Official documentation https://grafana.com/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/API documentation https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#create-a-token |
| 7 | + Required access policy scopes: |
| 8 | + accesspolicies:readaccesspolicies:writeaccesspolicies:delete |
| 9 | + This is similar to the grafana_cloud_access_policy_token resource, but it represents a token that will be rotated automatically over time. |
| 10 | +--- |
| 11 | + |
| 12 | +# grafana_cloud_access_policy_rotating_token (Resource) |
| 13 | + |
| 14 | +* [Official documentation](https://grafana.com/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/) |
| 15 | +* [API documentation](https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#create-a-token) |
| 16 | + |
| 17 | +Required access policy scopes: |
| 18 | + |
| 19 | +* accesspolicies:read |
| 20 | +* accesspolicies:write |
| 21 | +* accesspolicies:delete |
| 22 | + |
| 23 | +This is similar to the grafana_cloud_access_policy_token resource, but it represents a token that will be rotated automatically over time. |
| 24 | + |
| 25 | +## Example Usage |
| 26 | + |
| 27 | +```terraform |
| 28 | +data "grafana_cloud_organization" "current" { |
| 29 | + slug = "<your org slug>" |
| 30 | +} |
| 31 | +
|
| 32 | +resource "grafana_cloud_access_policy" "test" { |
| 33 | + region = "prod-us-east-0" |
| 34 | + name = "my-policy" |
| 35 | + display_name = "My Policy" |
| 36 | +
|
| 37 | + scopes = ["metrics:read", "logs:read"] |
| 38 | +
|
| 39 | + realm { |
| 40 | + type = "org" |
| 41 | + identifier = data.grafana_cloud_organization.current.id |
| 42 | +
|
| 43 | + label_policy { |
| 44 | + selector = "{namespace=\"default\"}" |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | +
|
| 49 | +resource "grafana_cloud_access_policy_rotating_token" "test" { |
| 50 | + region = "prod-us-east-0" |
| 51 | + access_policy_id = grafana_cloud_access_policy.test.policy_id |
| 52 | + name_prefix = "my-policy-rotating-token" |
| 53 | + display_name = "My Policy Rotating Token" |
| 54 | + expire_after = "30d" |
| 55 | + early_rotation_window = "24h" |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +<!-- schema generated by tfplugindocs --> |
| 60 | +## Schema |
| 61 | + |
| 62 | +### Required |
| 63 | + |
| 64 | +- `access_policy_id` (String) ID of the access policy for which to create a token. |
| 65 | +- `early_rotation_window` (String) Duration of the window before expiring where the token can be rotated (e.g. '24h', '30m', '1h30m'). |
| 66 | +- `expire_after` (String) Duration after which the token will expire (e.g. '24h', '30m', '1h30m'). |
| 67 | +- `name_prefix` (String) Prefix for the name of the access policy token. The actual name will be stored in the computed field `name`, which will be in the format '<name_prefix>-<expiration_timestamp>' |
| 68 | +- `region` (String) Region of the access policy. Should be set to the same region as the access policy. Use the region list API to get the list of available regions: https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/cloud-api/#list-regions. |
| 69 | + |
| 70 | +### Optional |
| 71 | + |
| 72 | +- `delete_on_destroy` (Boolean) Deletes the token in Grafana Cloud when the resource is destroyed in Terraform, instead of leaving it to expire at its `expires_at` time. Use it with `lifecycle { create_before_destroy = true }` to make sure that the new token is created before the old one is deleted. Defaults to `false`. |
| 73 | +- `display_name` (String) Display name of the access policy token. Defaults to the name. |
| 74 | + |
| 75 | +### Read-Only |
| 76 | + |
| 77 | +- `created_at` (String) Creation date of the access policy token. |
| 78 | +- `expires_at` (String) Expiration date of the access policy token. |
| 79 | +- `id` (String) The ID of this resource. |
| 80 | +- `name` (String) Name of the access policy token. |
| 81 | +- `ready_for_rotation` (Boolean) Signals that the token is either expired or within the period to be early rotated. |
| 82 | +- `token` (String, Sensitive) |
| 83 | +- `updated_at` (String) Last update date of the access policy token. |
| 84 | + |
| 85 | +## Import |
| 86 | + |
| 87 | +Import is supported using the following syntax: |
| 88 | + |
| 89 | +```shell |
| 90 | +terraform import grafana_cloud_access_policy_rotating_token.name "{{ region }}:{{ tokenId }}" |
| 91 | +``` |
0 commit comments