Skip to content

Commit 5c433e8

Browse files
GokceGKmarceljk
andauthored
Onboard logs service access token (#1165)
* onboard logs access token resource * fixes in acceptance test * use correct config variable in test * remove access-token field * separate model for resource and datasource * ignore lifetime field in acceptance test import section * add info about the lifetime field in examples * review changes * Update stackit/internal/services/logs/logs_acc_test.go Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com> * review changes * Update stackit/internal/services/logs/accesstoken/resource.go Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com> * review changes --------- Co-authored-by: Marcel Jacek <72880145+marceljk@users.noreply.github.com>
1 parent e99da3b commit 5c433e8

12 files changed

Lines changed: 1674 additions & 6 deletions

File tree

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: "stackit_logs_access_token Data Source - stackit"
4+
subcategory: ""
5+
description: |-
6+
Logs access token data source schema.
7+
~> This datasource is in beta and may be subject to breaking changes in the future. Use with caution. See our guide https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/guides/opting_into_beta_resources for how to opt-in to use beta resources.
8+
---
9+
10+
# stackit_logs_access_token (Data Source)
11+
12+
Logs access token data source schema.
13+
14+
~> This datasource is in beta and may be subject to breaking changes in the future. Use with caution. See our [guide](https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/guides/opting_into_beta_resources) for how to opt-in to use beta resources.
15+
16+
## Example Usage
17+
18+
```terraform
19+
data "stackit_logs_access_token" "accessToken" {
20+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
21+
region = "eu01"
22+
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
23+
access_token_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
24+
}
25+
```
26+
27+
<!-- schema generated by tfplugindocs -->
28+
## Schema
29+
30+
### Required
31+
32+
- `access_token_id` (String) The access token ID
33+
- `instance_id` (String) The Logs instance ID associated with the access token
34+
- `project_id` (String) STACKIT project ID associated with the Logs access token
35+
36+
### Optional
37+
38+
- `region` (String) STACKIT region name the resource is located in. If not defined, the provider region is used.
39+
40+
### Read-Only
41+
42+
- `creator` (String) The user who created the access token
43+
- `description` (String) The description of the access token
44+
- `display_name` (String) The displayed name of the access token
45+
- `expires` (Boolean) Indicates if the access token can expire
46+
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`instance_id`,`access_token_id`".
47+
- `permissions` (List of String) The access permissions granted to the access token. Possible values: `read`, `write`.
48+
- `status` (String) The status of the access token. Possible values are: `active`, `expired`.
49+
- `valid_until` (String) The date and time until an access token is valid to (inclusively)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stackit_logs_access_token Resource - stackit"
4+
subcategory: ""
5+
description: |-
6+
Logs access token resource schema.
7+
~> This resource is in beta and may be subject to breaking changes in the future. Use with caution. See our guide https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/guides/opting_into_beta_resources for how to opt-in to use beta resources.
8+
---
9+
10+
# stackit_logs_access_token (Resource)
11+
12+
Logs access token resource schema.
13+
14+
~> This resource is in beta and may be subject to breaking changes in the future. Use with caution. See our [guide](https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/guides/opting_into_beta_resources) for how to opt-in to use beta resources.
15+
16+
## Example Usage
17+
18+
```terraform
19+
resource "stackit_logs_access_token" "accessToken" {
20+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
21+
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
22+
region = "eu01"
23+
display_name = "logs-access-token-example"
24+
permissions = [
25+
"read"
26+
]
27+
}
28+
29+
resource "stackit_logs_access_token" "accessToken2" {
30+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
31+
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
32+
region = "eu01"
33+
display_name = "logs-access-token-example"
34+
lifetime = 30
35+
permissions = [
36+
"write"
37+
]
38+
description = "Example description"
39+
}
40+
41+
# Only use the import statement, if you want to import an existing logs access token
42+
# Note: The generated access token is only available upon creation.
43+
# Since this attribute is not fetched from the API call, to prevent the conflicts, you need to add:
44+
# lifecycle {
45+
# ignore_changes = [ lifetime ]
46+
# }
47+
import {
48+
to = stackit_logs_access_token.import-example
49+
id = "${var.project_id},${var.region},${var.logs_instance_id},${var.logs_access_token_id}"
50+
}
51+
```
52+
53+
<!-- schema generated by tfplugindocs -->
54+
## Schema
55+
56+
### Required
57+
58+
- `display_name` (String) The displayed name of the access token
59+
- `instance_id` (String) The Logs instance ID associated with the access token
60+
- `permissions` (List of String) The access permissions granted to the access token. Possible values: `read`, `write`.
61+
- `project_id` (String) STACKIT project ID associated with the Logs access token
62+
63+
### Optional
64+
65+
- `description` (String) The description of the access token
66+
- `lifetime` (Number) A lifetime period for an access token in days. If unset the token will not expire.
67+
- `region` (String) STACKIT region name the resource is located in. If not defined, the provider region is used.
68+
69+
### Read-Only
70+
71+
- `access_token` (String, Sensitive) The generated access token
72+
- `access_token_id` (String) The access token ID
73+
- `creator` (String) The user who created the access token
74+
- `expires` (Boolean) Indicates if the access token can expire
75+
- `id` (String) Terraform's internal resource identifier. It is structured as "`project_id`,`region`,`instance_id`,`access_token_id`".
76+
- `status` (String) The status of the access token. Possible values are: `active`, `expired`.
77+
- `valid_until` (String) The date and time until an access token is valid to (inclusively)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
data "stackit_logs_access_token" "accessToken" {
2+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
3+
region = "eu01"
4+
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
5+
access_token_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
6+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
resource "stackit_logs_access_token" "accessToken" {
2+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
3+
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
4+
region = "eu01"
5+
display_name = "logs-access-token-example"
6+
permissions = [
7+
"read"
8+
]
9+
}
10+
11+
resource "stackit_logs_access_token" "accessToken2" {
12+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
13+
instance_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
14+
region = "eu01"
15+
display_name = "logs-access-token-example"
16+
lifetime = 30
17+
permissions = [
18+
"write"
19+
]
20+
description = "Example description"
21+
}
22+
23+
# Only use the import statement, if you want to import an existing logs access token
24+
# Note: The generated access token is only available upon creation.
25+
# Since this attribute is not fetched from the API call, to prevent the conflicts, you need to add:
26+
# lifecycle {
27+
# ignore_changes = [ lifetime ]
28+
# }
29+
import {
30+
to = stackit_logs_access_token.import-example
31+
id = "${var.project_id},${var.region},${var.logs_instance_id},${var.logs_access_token_id}"
32+
}

0 commit comments

Comments
 (0)