Skip to content

Commit 5320e0c

Browse files
h3adexrubenhoenle
andauthored
chore(provider): mark deprecation for service_account_token (#920)
* chore(provider): make deprecation for service_account_token --------- Signed-off-by: Mauritz Uphoff <mauritz.uphoff@stackit.cloud> Co-authored-by: Ruben Hoenle <Ruben.Hoenle@stackit.cloud>
1 parent 54b483d commit 5320e0c

File tree

8 files changed

+26
-9
lines changed

8 files changed

+26
-9
lines changed

CONTRIBUTION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ To test your changes locally, you have to compile the provider (requires Go 1.24
121121

122122
1. Go to the copied example and initialize Terraform by running `terraform init -reconfigure -upgrade`. This will throw an error ("Failed to query available provider packages") which can be ignored since we are using the local provider build.
123123
> Note: Terraform will store its resources' states locally. To allow multiple people to use the same resources, check [Setup for multi-person usage](#setup-centralized-terraform-state)
124-
1. Setup authentication by setting the env var `STACKIT_SERVICE_ACCOUNT_TOKEN` as a valid token (see [Authentication](#authentication) for more details on how to autenticate).
124+
1. Setup authentication (see [Authentication](#authentication) for more details on how to authenticate).
125125
1. Run `terraform plan` or `terraform apply` commands.
126126
1. To debug the terraform provider, execute the following steps:
127127
* install the compiled terraform provider to binary path defined in the .terraformrc file

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Check one of the examples in the [examples](examples/) folder.
3737
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 the necessary permissions to it, e.g. `project.owner`. There are multiple ways to authenticate:
3838

3939
- Key flow (recommended)
40-
- Token flow
40+
- Token flow (is scheduled for deprecation and will be removed on December 17, 2025.)
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

@@ -112,6 +112,8 @@ To configure the key flow, follow this steps:
112112
113113
### Token flow
114114

115+
> Is scheduled for deprecation and will be removed on December 17, 2025.
116+
115117
Using this flow is less secure since the token is long-lived. You can provide the token in several ways:
116118

117119
1. Setting the field `service_account_token` in the provider

docs/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ provider "stackit" {
1111
1212
# Authentication
1313
14-
# Token flow
14+
# Token flow (scheduled for deprecation and will be removed on December 17, 2025)
1515
provider "stackit" {
1616
default_region = "eu01"
1717
service_account_token = var.service_account_token
@@ -37,7 +37,7 @@ provider "stackit" {
3737
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)
40-
- Token flow
40+
- Token flow (is scheduled for deprecation and will be removed on December 17, 2025)
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

@@ -112,6 +112,8 @@ To configure the key flow, follow this steps:
112112

113113
### Token flow
114114

115+
> Is scheduled for deprecation and will be removed on December 17, 2025.
116+
115117
Using this flow is less secure since the token is long-lived. You can provide the token in several ways:
116118

117119
1. Setting the field `service_account_token` in the provider
@@ -182,7 +184,7 @@ Note: AWS specific checks must be skipped as they do not work on STACKIT. For de
182184
- `service_account_email` (String, Deprecated) Service account email. It can also be set using the environment variable STACKIT_SERVICE_ACCOUNT_EMAIL. It is required if you want to use the resource manager project resource.
183185
- `service_account_key` (String) Service account key used for authentication. If set, the key flow will be used to authenticate all operations.
184186
- `service_account_key_path` (String) Path for the service account key used for authentication. If set, the key flow will be used to authenticate all operations.
185-
- `service_account_token` (String) Token used for authentication. If set, the token flow will be used to authenticate all operations.
187+
- `service_account_token` (String, Deprecated) Token used for authentication. If set, the token flow will be used to authenticate all operations.
186188
- `service_enablement_custom_endpoint` (String) Custom endpoint for the Service Enablement API
187189
- `ske_custom_endpoint` (String) Custom endpoint for the Kubernetes Engine (SKE) service
188190
- `sqlserverflex_custom_endpoint` (String) Custom endpoint for the SQL Server Flex service

docs/resources/service_account_access_token.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ page_title: "stackit_service_account_access_token Resource - stackit"
44
subcategory: ""
55
description: |-
66
Service account access token schema.
7+
!> This resource is scheduled for deprecation and will be removed on December 17, 2025. To ensure a smooth transition, please refer to our migration guide at https://docs.stackit.cloud/stackit/en/deprecation-plan-for-service-account-access-tokens-and-migration-guide-373293307.html for detailed instructions and recommendations.
78
Example Usage
89
Automatically rotate access tokens
910
@@ -30,6 +31,9 @@ description: |-
3031
# stackit_service_account_access_token (Resource)
3132

3233
Service account access token schema.
34+
35+
!> This resource is scheduled for deprecation and will be removed on December 17, 2025. To ensure a smooth transition, please refer to our migration guide at https://docs.stackit.cloud/stackit/en/deprecation-plan-for-service-account-access-tokens-and-migration-guide-373293307.html for detailed instructions and recommendations.
36+
3337
## Example Usage
3438

3539

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ provider "stackit" {
44

55
# Authentication
66

7-
# Token flow
7+
# Token flow (scheduled for deprecation and will be removed on December 17, 2025)
88
provider "stackit" {
99
default_region = "eu01"
1010
service_account_token = var.service_account_token

stackit/internal/services/serviceaccount/token/resource.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (r *serviceAccountTokenResource) Schema(_ context.Context, _ resource.Schem
8585
descriptions := map[string]string{
8686
"id": "Terraform's internal resource identifier. It is structured as \"`project_id`,`service_account_email`,`access_token_id`\".",
8787
"main": "Service account access token schema.",
88+
"deprecation_message": "This resource is scheduled for deprecation and will be removed on December 17, 2025. To ensure a smooth transition, please refer to our migration guide at https://docs.stackit.cloud/stackit/en/deprecation-plan-for-service-account-access-tokens-and-migration-guide-373293307.html for detailed instructions and recommendations.",
8889
"project_id": "STACKIT project ID associated with the service account token.",
8990
"service_account_email": "Email address linked to the service account.",
9091
"ttl_days": "Specifies the token's validity duration in days. If unspecified, defaults to 90 days.",
@@ -96,9 +97,9 @@ func (r *serviceAccountTokenResource) Schema(_ context.Context, _ resource.Schem
9697
"valid_until": "Estimated expiration timestamp of the access token. For precise validity, check the JWT details.",
9798
}
9899
resp.Schema = schema.Schema{
99-
MarkdownDescription: fmt.Sprintf("%s%s", descriptions["main"], markdownDescription),
100+
MarkdownDescription: fmt.Sprintf("%s\n\n!> %s\n%s", descriptions["main"], descriptions["deprecation_message"], markdownDescription),
100101
Description: descriptions["main"],
101-
DeprecationMessage: "This resource is scheduled for deprecation and will be removed on December 17, 2025. To ensure a smooth transition, please refer to our migration guide at https://docs.stackit.cloud/stackit/en/deprecation-plan-for-service-account-access-tokens-and-migration-guide-373293307.html for detailed instructions and recommendations.",
102+
DeprecationMessage: descriptions["deprecation_message"],
102103
Attributes: map[string]schema.Attribute{
103104
"id": schema.StringAttribute{
104105
Description: descriptions["id"],
@@ -169,6 +170,7 @@ func (r *serviceAccountTokenResource) Schema(_ context.Context, _ resource.Schem
169170

170171
// Create creates the resource and sets the initial Terraform state for service accounts.
171172
func (r *serviceAccountTokenResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { // nolint:gocritic // function signature required by Terraform
173+
core.LogAndAddWarning(ctx, &resp.Diagnostics, "stackit_service_account_access_token resource deprecated", "use stackit_service_account_key resource instead")
172174
// Retrieve the planned values for the resource.
173175
var model Model
174176
diags := req.Plan.Get(ctx, &model)
@@ -216,6 +218,7 @@ func (r *serviceAccountTokenResource) Create(ctx context.Context, req resource.C
216218

217219
// Read refreshes the Terraform state with the latest service account data.
218220
func (r *serviceAccountTokenResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { // nolint:gocritic // function signature required by Terraform
221+
core.LogAndAddWarning(ctx, &resp.Diagnostics, "stackit_service_account_access_token resource deprecated", "use stackit_service_account_key resource instead")
219222
// Retrieve the current state of the resource.
220223
var model Model
221224
diags := req.State.Get(ctx, &model)
@@ -284,6 +287,7 @@ func (r *serviceAccountTokenResource) Update(ctx context.Context, _ resource.Upd
284287

285288
// Delete deletes the service account and removes it from the Terraform state on success.
286289
func (r *serviceAccountTokenResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { // nolint:gocritic // function signature required by Terraform
290+
core.LogAndAddWarning(ctx, &resp.Diagnostics, "stackit_service_account_access_token resource deprecated", "use stackit_service_account_key resource instead")
287291
// Retrieve current state of the resource.
288292
var model Model
289293
diags := req.State.Get(ctx, &model)

stackit/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ func (p *Provider) Schema(_ context.Context, _ provider.SchemaRequest, resp *pro
204204
"service_account_token": schema.StringAttribute{
205205
Optional: true,
206206
Description: descriptions["service_account_token"],
207+
DeprecationMessage: "Authentication via Service Account Token is deprecated and will be removed on December 17, 2025. " +
208+
"Please use `service_account_key` or `service_account_key_path` instead. " +
209+
"For a smooth transition, refer to our migration guide: https://docs.stackit.cloud/stackit/en/deprecation-plan-for-service-account-access-tokens-and-migration-guide-373293307.html",
207210
},
208211
"service_account_key_path": schema.StringAttribute{
209212
Optional: true,

templates/index.md.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The STACKIT Terraform provider is the official Terraform provider to integrate a
1111
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:
1212

1313
- Key flow (recommended)
14-
- Token flow
14+
- Token flow (is scheduled for deprecation and will be removed on December 17, 2025)
1515

1616
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:
1717

@@ -86,6 +86,8 @@ To configure the key flow, follow this steps:
8686

8787
### Token flow
8888

89+
> Is scheduled for deprecation and will be removed on December 17, 2025.
90+
8991
Using this flow is less secure since the token is long-lived. You can provide the token in several ways:
9092

9193
1. Setting the field `service_account_token` in the provider

0 commit comments

Comments
 (0)