Open
Description
Terraform Version
1.12.1
Terraform Grafana Provider Version
3.24.1
Grafana Version
12.1
Affected Resource(s)
- grafana_role_assignment_item
- grafana_cloud_stack_service_account
- grafana_role_assignment
Terraform Configuration Files
resource "grafana_cloud_stack_service_account" "test" {
stack_slug = "test-slug"
name = "test"
role = "None"
is_disabled = false
}
data "grafana_role" "irm_reader" {
name = "plugins:grafana-irm-app:reader"
}
resource "grafana_role_assignment_item" "test" {
role_uid = data.grafana_role.irm_reader.uid
service_account_id = grafana_cloud_stack_service_account.test.id
}
resource "grafana_role_assignment_item" "test" {
role_uid = data.grafana_role.irm_reader.uid
service_account_id = grafana_cloud_stack_service_account.test.id
}
Expected Behavior
I would expect to be able to pass the cloud stack service account id directly to the grafana_role_assignment_item resource. I assume this also impacts grafana_role_assignment
but haven't tested.
Actual Behavior
grafana_role_assignment_item.test: Creating...
╷
│ Error: Failed to parse service account ID
│
│ with grafana_role_assignment_item.test,
│ on service_accounts.tf line 146, in resource "grafana_role_assignment_item" "test":
│ 146: resource "grafana_role_assignment_item" "test" {
│
│ strconv.ParseInt: parsing "test-slug:2899": invalid syntax
Steps to Reproduce
- Create a grafana cloud stack
- define a grafana_cloud_stack_service_account resource in terraform
- Reference the id of the grafana_cloud_stack_service_account resource in a grafana_role_assignment_item resource.
- It will produce an invalid syntax error
Important Factoids
This is for Grafana Cloud. The id stored in state for the grafana_cloud_stack_service_account
has the stack name prepended to it. For example, "id": "stackname:9". The grafana_role_assignment_item
expects the id to just be the numeric id and not have the stack prepended to it. So you can't refernce a grafana_cloud_stack_service_account
id directly when creating the grafana_role_assignment_item
resource.
As a temporary workaround you can trim the stack prefix from the grafana_cloud_stack_service_account.test.id.
resource "grafana_role_assignment_item" "test" {
role_uid = data.grafana_role.irm_reader.uid
service_account_id = trimprefix(grafana_cloud_stack_service_account.test.id, "test-slug:")
}
References
No response
Metadata
Metadata
Assignees
Labels
No labels