From 57e74057bfafe83237ea58d7917e7131e1543030 Mon Sep 17 00:00:00 2001 From: Eric Leijonmarck Date: Wed, 5 Apr 2023 18:40:10 +0100 Subject: [PATCH 1/3] add: deprecation message of terraform using api keys --- internal/resources/cloud/resource_cloud_api_key.go | 1 + internal/resources/grafana/resource_api_key.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/resources/cloud/resource_cloud_api_key.go b/internal/resources/cloud/resource_cloud_api_key.go index 5cbb9ff5c..f6dd553ec 100644 --- a/internal/resources/cloud/resource_cloud_api_key.go +++ b/internal/resources/cloud/resource_cloud_api_key.go @@ -25,6 +25,7 @@ func ResourceAPIKey() *schema.Resource { Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, + DeprecationMessage: "Use `grafana_cloud_stack_service_account` together with `grafana_cloud_stack_service_account_token` resources instead see https://grafana.com/docs/grafana/next/administration/api-keys/#migrate-api-keys-to-grafana-service-accounts-using-terraform", Schema: map[string]*schema.Schema{ "cloud_org_slug": { diff --git a/internal/resources/grafana/resource_api_key.go b/internal/resources/grafana/resource_api_key.go index 14925682d..0a6f99464 100644 --- a/internal/resources/grafana/resource_api_key.go +++ b/internal/resources/grafana/resource_api_key.go @@ -20,9 +20,10 @@ Manages Grafana API Keys. * [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/auth/) `, - CreateContext: resourceAPIKeyCreate, - ReadContext: resourceAPIKeyRead, - DeleteContext: resourceAPIKeyDelete, + CreateContext: resourceAPIKeyCreate, + ReadContext: resourceAPIKeyRead, + DeleteContext: resourceAPIKeyDelete, + DeprecationMessage: "Use `grafana_service_account` together with `grafana_cloud_stack_service_account_token` resources instead see https://grafana.com/docs/grafana/next/administration/api-keys/#migrate-api-keys-to-grafana-service-accounts-using-terraform", Schema: map[string]*schema.Schema{ "org_id": orgIDAttribute(), From 560be4ceabc8362519afe186ef40d50e86499b9e Mon Sep 17 00:00:00 2001 From: Eric Leijonmarck Date: Thu, 6 Apr 2023 09:20:09 +0100 Subject: [PATCH 2/3] deleted files --- docs/resources/api_key.md | 61 --------------------------------- docs/resources/cloud_api_key.md | 45 ------------------------ 2 files changed, 106 deletions(-) delete mode 100644 docs/resources/api_key.md delete mode 100644 docs/resources/cloud_api_key.md diff --git a/docs/resources/api_key.md b/docs/resources/api_key.md deleted file mode 100644 index 8fd456edc..000000000 --- a/docs/resources/api_key.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "grafana_api_key Resource - terraform-provider-grafana" -subcategory: "Grafana OSS" -description: |- - Manages Grafana API Keys. - HTTP API https://grafana.com/docs/grafana/latest/developers/http_api/auth/ ---- - -# grafana_api_key (Resource) - -Manages Grafana API Keys. - -* [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/auth/) - -## Example Usage - -```terraform -resource "grafana_api_key" "foo" { - name = "key_foo" - role = "Viewer" -} - -resource "grafana_api_key" "bar" { - name = "key_bar" - role = "Admin" - seconds_to_live = 30 -} - - -output "api_key_foo_key_only" { - value = grafana_api_key.foo.key - sensitive = true -} - -output "api_key_bar" { - value = grafana_api_key.bar -} -``` - - -## Schema - -### Required - -- `name` (String) -- `role` (String) - -### Optional - -- `cloud_stack_slug` (String, Deprecated) Deprecated: Use `grafana_cloud_stack_service_account` and `grafana_cloud_stack_service_account_token` resources instead -- `org_id` (String) The Organization ID. If not set, the Org ID defined in the provider block will be used. -- `seconds_to_live` (Number) - -### Read-Only - -- `expiration` (String) -- `id` (String) The ID of this resource. -- `key` (String, Sensitive) - - diff --git a/docs/resources/cloud_api_key.md b/docs/resources/cloud_api_key.md deleted file mode 100644 index f5564f644..000000000 --- a/docs/resources/cloud_api_key.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "grafana_cloud_api_key Resource - terraform-provider-grafana" -subcategory: "Cloud" -description: |- - Manages a single API key on the Grafana Cloud portal (on the organization level) - * API documentation https://grafana.com/docs/grafana-cloud/reference/cloud-api/#api-keys ---- - -# grafana_cloud_api_key (Resource) - -Manages a single API key on the Grafana Cloud portal (on the organization level) -* [API documentation](https://grafana.com/docs/grafana-cloud/reference/cloud-api/#api-keys) - -## Example Usage - -```terraform -resource "grafana_cloud_api_key" "test" { - cloud_org_slug = "myorg" - name = "my-key" - role = "Admin" -} -``` - - -## Schema - -### Required - -- `cloud_org_slug` (String) The slug of the organization to create the API key in. This is the same slug as the organization name in the URL. -- `name` (String) Name of the API key. -- `role` (String) Role of the API key. Should be one of [Viewer Editor Admin MetricsPublisher PluginPublisher]. See https://grafana.com/docs/grafana-cloud/api/#create-api-key for details. - -### Read-Only - -- `id` (String) The ID of this resource. -- `key` (String, Sensitive) The generated API key. - -## Import - -Import is supported using the following syntax: - -```shell -terraform import grafana_cloud_api_key.resource_name "{{org-name}}-{{api_key_name}}" -``` From 7fd3ff3afb0d8bde5287ef60c5fa67e78bb5bb62 Mon Sep 17 00:00:00 2001 From: Eric Leijonmarck Date: Tue, 11 Apr 2023 08:52:08 +0100 Subject: [PATCH 3/3] Update internal/resources/grafana/resource_api_key.go Co-authored-by: Julien Duchesne --- internal/resources/grafana/resource_api_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/resources/grafana/resource_api_key.go b/internal/resources/grafana/resource_api_key.go index 0a6f99464..0c4bdf39e 100644 --- a/internal/resources/grafana/resource_api_key.go +++ b/internal/resources/grafana/resource_api_key.go @@ -23,7 +23,7 @@ Manages Grafana API Keys. CreateContext: resourceAPIKeyCreate, ReadContext: resourceAPIKeyRead, DeleteContext: resourceAPIKeyDelete, - DeprecationMessage: "Use `grafana_service_account` together with `grafana_cloud_stack_service_account_token` resources instead see https://grafana.com/docs/grafana/next/administration/api-keys/#migrate-api-keys-to-grafana-service-accounts-using-terraform", + DeprecationMessage: "Use `grafana_service_account` together with `grafana_service_account_token` instead, see https://grafana.com/docs/grafana/next/administration/api-keys/#migrate-api-keys-to-grafana-service-accounts-using-terraform", Schema: map[string]*schema.Schema{ "org_id": orgIDAttribute(),