Skip to content

Commit f09610a

Browse files
authored
Support to manage basic k6 resources (#2129)
* Base support for GCk6 projects * Support for GCk6 load tests and scripts * Support for GCk6 project limits * k6 App installation resource * Generate docs for k6 resources * Accommodate tests checks * k6 data sources: project, limits and load tests * Add an example for grafana_k6_installation * Update CODEOWNERS with k6 * Set up k6 credentials for cloud instance tests * Filter project's load tests by name * Fetch projects by name * Add 'grafana_folder_uid' to k6 project model
1 parent 1555feb commit f09610a

File tree

60 files changed

+3519
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3519
-3
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/internal/resources/connections/* @grafana/platform-monitoring @grafana/middleware-apps
99
/internal/resources/fleetmanagement/* @grafana/platform-monitoring @grafana/fleet-management-backend
1010
/internal/resources/frontendo11y/* @grafana/platform-monitoring @grafana/frontend-o11y
11+
/internal/resources/k6/* @grafana/platform-monitoring @grafana/k6-core
1112
/internal/resources/machinelearning/* @grafana/platform-monitoring @grafana/machine-learning
1213
/internal/resources/oncall/* @grafana/platform-monitoring @grafana/grafana-irm-backend
1314
/internal/resources/slo/* @grafana/platform-monitoring @grafana/slo-squad

.github/workflows/acc-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ jobs:
4747
with:
4848
repo_secrets: |
4949
GRAFANA_AUTH=cloud-instance-tests:auth
50+
GRAFANA_STACK_ID=cloud-instance-k6-tests:stack-id
5051
GRAFANA_ONCALL_ACCESS_TOKEN=cloud-instance-tests:oncall-token
5152
GRAFANA_SM_ACCESS_TOKEN=cloud-instance-tests:sm-token
53+
GRAFANA_K6_ACCESS_TOKEN=cloud-instance-k6-tests:k6-token
5254
GRAFANA_SM_URL=cloud-instance-tests:sm-url
5355
GRAFANA_URL=cloud-instance-tests:url
5456
GRAFANA_CLOUD_PROVIDER_URL=cloudprovider-tests:url

docs/data-sources/k6_load_test.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_k6_load_test Data Source - terraform-provider-grafana"
4+
subcategory: "k6"
5+
description: |-
6+
Retrieves a k6 load test.
7+
---
8+
9+
# grafana_k6_load_test (Data Source)
10+
11+
Retrieves a k6 load test.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "grafana_k6_project" "load_test_project" {
17+
name = "Terraform Load Test Project"
18+
}
19+
20+
resource "grafana_k6_load_test" "test_load_test" {
21+
project_id = grafana_k6_project.load_test_project.id
22+
name = "Terraform Test Load Test"
23+
script = <<-EOT
24+
export default function() {
25+
console.log('Hello from k6!');
26+
}
27+
EOT
28+
}
29+
30+
data "grafana_k6_load_test" "from_id" {
31+
id = grafana_k6_load_test.test_load_test.id
32+
}
33+
```
34+
35+
<!-- schema generated by tfplugindocs -->
36+
## Schema
37+
38+
### Required
39+
40+
- `id` (Number) Numeric identifier of the load test.
41+
42+
### Read-Only
43+
44+
- `baseline_test_run_id` (Number) Identifier of a baseline test run used for results comparison.
45+
- `created` (String) The date when the load test was created.
46+
- `name` (String) Human-friendly identifier of the load test.
47+
- `project_id` (Number) The identifier of the project this load test belongs to.
48+
- `script` (String) The k6 test script content.
49+
- `updated` (String) The date when the load test was last updated.

docs/data-sources/k6_load_tests.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_k6_load_tests Data Source - terraform-provider-grafana"
4+
subcategory: "k6"
5+
description: |-
6+
Retrieves all k6 load tests that belong to a project.
7+
---
8+
9+
# grafana_k6_load_tests (Data Source)
10+
11+
Retrieves all k6 load tests that belong to a project.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "grafana_k6_project" "load_test_project" {
17+
name = "Terraform Load Test Project"
18+
}
19+
20+
resource "grafana_k6_load_test" "test_load_test" {
21+
project_id = grafana_k6_project.load_test_project.id
22+
name = "Terraform Test Load Test"
23+
script = <<-EOT
24+
export default function() {
25+
console.log('Hello from k6!');
26+
}
27+
EOT
28+
29+
depends_on = [
30+
grafana_k6_project.load_test_project,
31+
]
32+
}
33+
34+
resource "grafana_k6_load_test" "test_load_test_2" {
35+
project_id = grafana_k6_project.load_test_project.id
36+
name = "Terraform Test Load Test (2)"
37+
script = <<-EOT
38+
export default function() {
39+
console.log('Hello from k6!');
40+
}
41+
EOT
42+
43+
depends_on = [
44+
grafana_k6_load_test.test_load_test,
45+
]
46+
}
47+
48+
data "grafana_k6_load_tests" "from_project_id" {
49+
project_id = grafana_k6_project.load_test_project.id
50+
51+
depends_on = [
52+
grafana_k6_load_test.test_load_test,
53+
grafana_k6_load_test.test_load_test_2
54+
]
55+
}
56+
57+
data "grafana_k6_load_tests" "filter_by_name" {
58+
name = "Terraform Test Load Test (2)"
59+
project_id = grafana_k6_project.load_test_project.id
60+
61+
depends_on = [
62+
grafana_k6_load_test.test_load_test_2,
63+
]
64+
}
65+
```
66+
67+
<!-- schema generated by tfplugindocs -->
68+
## Schema
69+
70+
### Required
71+
72+
- `project_id` (Number) The identifier of the project the load tests belong to.
73+
74+
### Optional
75+
76+
- `name` (String) Human-friendly identifier of the load test.
77+
78+
### Read-Only
79+
80+
- `id` (Number) The identifier of the project the load tests belong to. This is set to the same as the project_id.
81+
- `load_tests` (List of Object) (see [below for nested schema](#nestedatt--load_tests))
82+
83+
<a id="nestedatt--load_tests"></a>
84+
### Nested Schema for `load_tests`
85+
86+
Read-Only:
87+
88+
- `baseline_test_run_id` (Number)
89+
- `created` (String)
90+
- `id` (Number)
91+
- `name` (String)
92+
- `project_id` (Number)
93+
- `script` (String)
94+
- `updated` (String)

docs/data-sources/k6_project.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_k6_project Data Source - terraform-provider-grafana"
4+
subcategory: "k6"
5+
description: |-
6+
Retrieves a k6 project.
7+
---
8+
9+
# grafana_k6_project (Data Source)
10+
11+
Retrieves a k6 project.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "grafana_k6_project" "test" {
17+
name = "Terraform Test Project"
18+
}
19+
20+
data "grafana_k6_project" "from_id" {
21+
depends_on = [
22+
grafana_k6_project.test
23+
]
24+
id = grafana_k6_project.test.id
25+
}
26+
```
27+
28+
<!-- schema generated by tfplugindocs -->
29+
## Schema
30+
31+
### Required
32+
33+
- `id` (Number) Numeric identifier of the project.
34+
35+
### Read-Only
36+
37+
- `created` (String) The date when the project was created.
38+
- `grafana_folder_uid` (String) The Grafana folder uid.
39+
- `is_default` (Boolean) Whether this project is the default for running tests when no explicit project identifier is provided.
40+
- `name` (String) Human-friendly identifier of the project.
41+
- `updated` (String) The date when the project was last updated.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_k6_project_limits Data Source - terraform-provider-grafana"
4+
subcategory: "k6"
5+
description: |-
6+
Retrieves a k6 project limits.
7+
---
8+
9+
# grafana_k6_project_limits (Data Source)
10+
11+
Retrieves a k6 project limits.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "grafana_k6_project" "test_project_limits" {
17+
name = "Terraform Project Test Limits"
18+
}
19+
20+
data "grafana_k6_project_limits" "from_project_id" {
21+
project_id = grafana_k6_project.test_project_limits.id
22+
}
23+
```
24+
25+
<!-- schema generated by tfplugindocs -->
26+
## Schema
27+
28+
### Required
29+
30+
- `project_id` (Number) The identifier of the project to get limits for.
31+
32+
### Read-Only
33+
34+
- `duration_max_per_test` (Number) Maximum duration of a test in seconds.
35+
- `id` (Number) The identifier of the project limits. This is set to the same as the project_id.
36+
- `vu_browser_max_per_test` (Number) Maximum number of concurrent browser virtual users (VUs) used in one test.
37+
- `vu_max_per_test` (Number) Maximum number of concurrent virtual users (VUs) used in one test.
38+
- `vuh_max_per_month` (Number) Maximum amount of virtual user hours (VU/h) used per one calendar month.

docs/data-sources/k6_projects.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "grafana_k6_projects Data Source - terraform-provider-grafana"
4+
subcategory: "k6"
5+
description: |-
6+
Retrieves all k6 projects with the given name.
7+
---
8+
9+
# grafana_k6_projects (Data Source)
10+
11+
Retrieves all k6 projects with the given name.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "grafana_k6_project" "project" {
17+
name = "Terraform Test Project"
18+
}
19+
20+
resource "grafana_k6_project" "project_2" {
21+
name = "Terraform Test Project"
22+
}
23+
24+
data "grafana_k6_projects" "from_name" {
25+
name = "Terraform Test Project"
26+
27+
depends_on = [
28+
grafana_k6_project.project,
29+
grafana_k6_project.project_2
30+
]
31+
32+
}
33+
```
34+
35+
<!-- schema generated by tfplugindocs -->
36+
## Schema
37+
38+
### Optional
39+
40+
- `name` (String) Human-friendly identifier of the project.
41+
42+
### Read-Only
43+
44+
- `id` (String) Human-friendly identifier of the project. This is set to the same as name.
45+
- `projects` (List of Object) (see [below for nested schema](#nestedatt--projects))
46+
47+
<a id="nestedatt--projects"></a>
48+
### Nested Schema for `projects`
49+
50+
Read-Only:
51+
52+
- `created` (String)
53+
- `grafana_folder_uid` (String)
54+
- `id` (Number)
55+
- `is_default` (Boolean)
56+
- `name` (String)
57+
- `updated` (String)

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ provider "grafana" {
280280
- `frontend_o11y_api_access_token` (String, Sensitive) A Grafana Frontend Observability API access token. May alternatively be set via the `GRAFANA_FRONTEND_O11Y_API_ACCESS_TOKEN` environment variable.
281281
- `http_headers` (Map of String, Sensitive) Optional. HTTP headers mapping keys to values used for accessing the Grafana and Grafana Cloud APIs. May alternatively be set via the `GRAFANA_HTTP_HEADERS` environment variable in JSON format.
282282
- `insecure_skip_verify` (Boolean) Skip TLS certificate verification. May alternatively be set via the `GRAFANA_INSECURE_SKIP_VERIFY` environment variable.
283+
- `k6_access_token` (String, Sensitive) The k6 Cloud API token. May alternatively be set via the `GRAFANA_K6_ACCESS_TOKEN` environment variable.
284+
- `k6_url` (String) The k6 Cloud API url. May alternatively be set via the `GRAFANA_K6_URL` environment variable.
283285
- `oncall_access_token` (String, Sensitive) A Grafana OnCall access token. May alternatively be set via the `GRAFANA_ONCALL_ACCESS_TOKEN` environment variable.
284286
- `oncall_url` (String) An Grafana OnCall backend address. May alternatively be set via the `GRAFANA_ONCALL_URL` environment variable.
285287
- `org_id` (Number) The Grafana org ID, if you are using a self-hosted OSS or enterprise Grafana instance. May alternatively be set via the `GRAFANA_ORG_ID` environment variable.

0 commit comments

Comments
 (0)