forgejo-terraform-provider/docs/resources/token.md
tobiasbp 167ce6ed80 add-scope-to-token (#33)
This PR adds the ability to set scopes for tokens (they can not be used for much without). Removed the _username_ from the _token resource_ as the owner can not be configured, as it will be owned by the user creating the resource.

As far as I can tell, it's not possible to modify the scopes for a existing token using the API, so a token created by the provider will be recreated if the list of scopes is updated. This reflects what is possible using the GUI.

This PR fixes this issue: https://gitea.com/gitea/terraform-provider-gitea/issues/32

Reviewed-on: https://gitea.com/gitea/terraform-provider-gitea/pulls/33
Co-authored-by: tobiasbp <tobiasbp@noreply.gitea.com>
Co-committed-by: tobiasbp <tobiasbp@noreply.gitea.com>
2023-11-16 00:52:35 +00:00

1.4 KiB

page_title subcategory description
gitea_token Resource - terraform-provider-gitea gitea_token manages gitea Access Tokens. Due to upstream limitations (see https://gitea.com/gitea/go-sdk/issues/610) this resource can only be used with username/password provider configuration. WARNING: Tokens will be stored in the terraform state!

gitea_token (Resource)

gitea_token manages gitea Access Tokens.

Due to upstream limitations (see https://gitea.com/gitea/go-sdk/issues/610) this resource can only be used with username/password provider configuration.

WARNING: Tokens will be stored in the terraform state!

Example Usage

provider "gitea" {
  base_url = var.gitea_url
  # Token Auth can not be used with this resource
  username = var.gitea_username
  password = var.gitea_password
}

// The token owner is the creator of the token
resource "gitea_token" "test_token" {
  name   = "test_token"
  scopes = ["all"]
}

output "token" {
  value     = resource.gitea_token.test_token.token
  sensitive = true
}

Schema

Required

  • name (String) The name of the Access Token
  • scopes (Set of String) List of string representations of scopes for the token

Read-Only

  • id (String) The ID of this resource.
  • last_eight (String)
  • token (String, Sensitive) The actual Access Token