add CLI authentication support for provider configuration #1076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add CLI Authentication Support
Overview
This PR implements CLI-based authentication for the Terraform provider, enabling users to authenticate using credentials from the STACKIT CLI without managing separate service account credentials. This addresses a longstanding user request for seamless authentication across STACKIT tools.
Related Issues & PRs
Closes: #719
Related Discussion: #880
Dependencies:
core/cliauthpackage andconfig.WithCLIProviderAuth())stackit auth provider logincommand)Motivation
Users currently need to create service accounts and manage credentials separately for Terraform, even when already authenticated with the STACKIT CLI. This creates friction and complexity, especially for personal development workflows.
As highlighted in issue #719:
Implementation
User-Facing Changes
Two new optional provider attributes:
Authentication Priority
The provider now follows this precedence:
service_account_key,service_account_key_path,token)cli_auth = trueand CLI is authenticated)sdkauth.SetupAuth())This ensures backward compatibility while providing a convenient default for interactive use.
Profile Resolution
When
cli_profileis not specified, the provider uses:STACKIT_CLI_PROFILEenvironment variable~/.config/stackit/cli-profile.txt"default"profileTechnical Details
The implementation leverages the SDK's new
config.WithCLIProviderAuth()function, which:Cross-platform credential storage:
~/.stackit/cli-provider-auth-storage.txtUsage Example
Before (Current Workflow)
After (With CLI Auth)
Design Decisions
Explicit Opt-In (RFC #880 Requirement)
The feature requires
cli_auth = trueto avoid confusion about authentication behavior. Users must consciously enable CLI authentication, making it clear where credentials originate.Minimal Coupling
The provider only depends on the SDK's configuration interface. All credential management, token refresh, and storage logic resides in the SDK's
core/cliauthpackage, maintaining clean separation of concerns.Backward Compatibility
Existing authentication methods continue to work unchanged. The new feature is purely additive, with no breaking changes to provider configuration or behavior.
Documentation Updates Needed
Migration Path
go.modto use SDK version with CLI auth supportChecklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)