Skip to content

Commit ee905a3

Browse files
authored
Deprecate stackit_loadbalancer_credential and add new stackit_loadbalancer_observability_credential (#357)
* Copy over old resource files * Adjustments to the new observability credential resource.go * Register new resource in the provider * Add example * Adapt acc test * Update docs * Add deprecation message * Fix linter * Add deprecation message to dscription
1 parent 6eb1310 commit ee905a3

9 files changed

Lines changed: 580 additions & 14 deletions

File tree

docs/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# STACKIT Provider
1+
# STACKIT Terraform Provider
22

3-
The STACKIT provider is the official Terraform provider to integrate all the resources developed by STACKIT.
3+
The STACKIT Terraform provider is the official Terraform provider to integrate all the resources developed by [STACKIT](https://www.stackit.de/en/).
44

55
## Example Usage
66

@@ -34,14 +34,14 @@ provider "stackit" {
3434

3535
## Authentication
3636

37-
To authenticate, you will need a [service account](https://docs.stackit.cloud/stackit/en/service-accounts-134415819.html). Create it in the STACKIT Portal an assign it the necessary permissions, e.g. `project.owner`. There are multiple ways to authenticate:
37+
To authenticate, you will need a [service account](https://docs.stackit.cloud/stackit/en/service-accounts-134415819.html). Create it in the [STACKIT Portal](https://portal.stackit.cloud/) and assign it the necessary permissions, e.g. `project.owner`. There are multiple ways to authenticate:
3838

3939
- Key flow (recommended)
4040
- Token flow
4141

4242
When setting up authentication, the provider will always try to use the key flow first and search for credentials in several locations, following a specific order:
4343

44-
1. Explicit configuration, e.g. by seting the field `stackit_service_account_key_path` in the provider block (see example below)
44+
1. Explicit configuration, e.g. by setting the field `stackit_service_account_key_path` in the provider block (see example below)
4545
2. Environment variable, e.g. by setting `STACKIT_SERVICE_ACCOUNT_KEY_PATH`
4646
3. Credentials file
4747

docs/resources/loadbalancer_credential.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ page_title: "stackit_loadbalancer_credential Resource - stackit"
44
subcategory: ""
55
description: |-
66
Load balancer credential resource schema. Must have a region specified in the provider configuration.
7+
!> The stackit_loadbalancer_credential resource has been deprecated and will be removed after November 13th 2024. Please use stackit_loadbalancer_observability_credential instead, which offers the exact same functionality.
78
---
89

910
# stackit_loadbalancer_credential (Resource)
1011

1112
Load balancer credential resource schema. Must have a `region` specified in the provider configuration.
1213

14+
!> The `stackit_loadbalancer_credential` resource has been deprecated and will be removed after November 13th 2024. Please use `stackit_loadbalancer_observability_credential` instead, which offers the exact same functionality.
15+
1316
## Example Usage
1417

1518
```terraform
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "stackit_loadbalancer_observability_credential Resource - stackit"
4+
subcategory: ""
5+
description: |-
6+
Load balancer observability credential resource schema. Must have a region specified in the provider configuration. These contain the username and password for the observability service (e.g. Argus) where the load balancer logs/metrics will be pushed into
7+
---
8+
9+
# stackit_loadbalancer_observability_credential (Resource)
10+
11+
Load balancer observability credential resource schema. Must have a `region` specified in the provider configuration. These contain the username and password for the observability service (e.g. Argus) where the load balancer logs/metrics will be pushed into
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "stackit_loadbalancer_observability_credential" "example" {
17+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
18+
display_name = "example-credentials"
19+
username = "example-user"
20+
password = "example-password"
21+
}
22+
```
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Required
28+
29+
- `display_name` (String) Observability credential name.
30+
- `password` (String) The username for the observability service (e.g. Argus) where the logs/metrics will be pushed into.
31+
- `project_id` (String) STACKIT project ID to which the load balancer observability credential is associated.
32+
- `username` (String) The password for the observability service (e.g. Argus) where the logs/metrics will be pushed into.
33+
34+
### Read-Only
35+
36+
- `credentials_ref` (String) The credentials reference is used by the Load Balancer to define which credentials it will use.
37+
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`credentials_ref`".
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "stackit_loadbalancer_observability_credential" "example" {
2+
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
3+
display_name = "example-credentials"
4+
username = "example-user"
5+
password = "example-password"
6+
}

stackit/internal/services/loadbalancer/credential/resource.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ func (r *credentialResource) Schema(_ context.Context, _ resource.SchemaRequest,
102102
"display_name": "Credential name.",
103103
"username": "The username used for the ARGUS instance.",
104104
"password": "The password used for the ARGUS instance.",
105+
"deprecation_message": "The `stackit_loadbalancer_credential` resource has been deprecated and will be removed after November 13th 2024. " +
106+
"Please use `stackit_loadbalancer_observability_credential` instead, which offers the exact same functionality.",
105107
}
106108

107109
resp.Schema = schema.Schema{
108-
Description: descriptions["main"],
110+
Description: fmt.Sprintf("%s\n%s", descriptions["main"], descriptions["deprecation_message"]),
111+
// Callout block: https://developer.hashicorp.com/terraform/registry/providers/docs#callouts
112+
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s", descriptions["main"], descriptions["deprecation_message"]),
113+
DeprecationMessage: descriptions["deprecation_message"],
109114
Attributes: map[string]schema.Attribute{
110115
"id": schema.StringAttribute{
111116
Description: descriptions["id"],

stackit/internal/services/loadbalancer/loadbalancer_acc_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func configResources(targetPort string) string {
9494
}
9595
}
9696
97-
resource "stackit_loadbalancer_credential" "credential" {
97+
resource "stackit_loadbalancer_observability_credential" "credential" {
9898
project_id = "%s"
9999
display_name = "%s"
100100
username = "%s"
@@ -245,13 +245,13 @@ func TestAccLoadBalancerResource(t *testing.T) {
245245

246246
// Credential
247247
resource.TestCheckResourceAttrPair(
248-
"stackit_loadbalancer_credential.credential", "project_id",
248+
"stackit_loadbalancer_observability_credential.credential", "project_id",
249249
"stackit_loadbalancer.loadbalancer", "project_id",
250250
),
251-
resource.TestCheckResourceAttrSet("stackit_loadbalancer_credential.credential", "credentials_ref"),
252-
resource.TestCheckResourceAttr("stackit_loadbalancer_credential.credential", "display_name", loadBalancerResource["credential_display_name"]),
253-
resource.TestCheckResourceAttr("stackit_loadbalancer_credential.credential", "username", loadBalancerResource["credential_username"]),
254-
resource.TestCheckResourceAttr("stackit_loadbalancer_credential.credential", "password", loadBalancerResource["credential_password"]),
251+
resource.TestCheckResourceAttrSet("stackit_loadbalancer_observability_credential.credential", "credentials_ref"),
252+
resource.TestCheckResourceAttr("stackit_loadbalancer_observability_credential.credential", "display_name", loadBalancerResource["credential_display_name"]),
253+
resource.TestCheckResourceAttr("stackit_loadbalancer_observability_credential.credential", "username", loadBalancerResource["credential_username"]),
254+
resource.TestCheckResourceAttr("stackit_loadbalancer_observability_credential.credential", "password", loadBalancerResource["credential_password"]),
255255
),
256256
},
257257
// Data source
@@ -318,11 +318,11 @@ func TestAccLoadBalancerResource(t *testing.T) {
318318
ImportStateVerify: true,
319319
},
320320
{
321-
ResourceName: "stackit_loadbalancer_credential.credential",
321+
ResourceName: "stackit_loadbalancer_observability_credential.credential",
322322
ImportStateIdFunc: func(s *terraform.State) (string, error) {
323-
r, ok := s.RootModule().Resources["stackit_loadbalancer_credential.credential"]
323+
r, ok := s.RootModule().Resources["stackit_loadbalancer_observability_credential.credential"]
324324
if !ok {
325-
return "", fmt.Errorf("couldn't find resource stackit_loadbalancer_credential.credential")
325+
return "", fmt.Errorf("couldn't find resource stackit_loadbalancer_observability_credential.credential")
326326
}
327327
credentialsRef, ok := r.Primary.Attributes["credentials_ref"]
328328
if !ok {

0 commit comments

Comments
 (0)