New resource 'tfe_org_max_token_ttl_policy' to create/update token time to live#1996
Open
sana-faraz wants to merge 10 commits intomainfrom
Open
New resource 'tfe_org_max_token_ttl_policy' to create/update token time to live#1996sana-faraz wants to merge 10 commits intomainfrom
sana-faraz wants to merge 10 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support in the Terraform TFE provider for managing and reading an organization’s maximum API token time-to-live (TTL) policy via a new resource and data source.
Changes:
- Introduces
tfe_org_max_token_ttl_policyresource with TTL validation/conversion and CRUD operations backed by the TFE API. - Introduces
tfe_org_max_token_ttl_policydata source returning TTL limits in milliseconds. - Adds acceptance tests and new documentation pages for both resource and data source.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
internal/provider/resource_tfe_org_max_token_ttl_policy.go |
Implements the new org max token TTL policy resource (schema, plan logic, CRUD, TTL parsing). |
internal/provider/data_source_tfe_org_max_token_ttl_policy.go |
Implements the new org max token TTL policy data source returning TTLs in milliseconds. |
internal/provider/provider_next.go |
Registers the new resource and data source with the framework provider. |
internal/provider/resource_tfe_org_max_token_ttl_policy_test.go |
Adds acceptance tests for the new resource. |
internal/provider/data_source_tfe_org_max_token_ttl_policy_test.go |
Adds acceptance tests for the new data source. |
website/docs/r/org_max_token_ttl_policy.html.markdown |
Adds resource documentation and examples. |
website/docs/d/org_max_token_ttl_policy.html.markdown |
Adds data source documentation and examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
debrin-hc
reviewed
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
'tfe_org_max_token_ttl_policy' manages the maximum time-to-live (TTL) policy for API tokens in an organization. When enabled, this policy enforces maximum lifespans for organization, team, audit trail, and user tokens. Any tokens that exceed the configured limits will be revoked. If disabled, the TTL defaults to 2 years
Remember to:
Testing plan
`
resource "tfe_organization" "new_org" {
name = "sanaOrg1"
email = "admin@company.com"
max_ttl_enabled = true
}
resource "tfe_org_max_token_ttl_policy" "token_ttl_policy" {
organization = tfe_organization.new_org.name
org_token_max_ttl = "2h"
user_token_max_ttl = "5y"
team_token_max_ttl = "10w"
}
organization- (Optional) Name of the organization. If omitted, organization must be defined in the provider config.org_token_max_ttl- (Optional) Maximum lifespan allowed for organization tokens to access the organization's resources. Defaults to two years (2y). Format:<number><unit>where unit ish(hours),d(days),w(weeks),mo(months), ory(years). Example 1h- 1 hourteam_token_max_ttl- (Optional) Maximum lifespan allowed for team tokens to access the organization's resources. Defaults to two years (2y). Format:<number><unit>where unit ish(hours),d(days),w(weeks),mo(months), ory(years). Example 1d- 1 dayaudit_trail_token_max_ttl- (Optional) Maximum lifespan allowed for audit trail tokens to access the organization's resources. Defaults to two years (2y). Format:<number><unit>where unit ish(hours),d(days),w(weeks),mo(months), ory(years). Example 1w- 1 weekuser_token_max_ttl- (Optional) Maximum lifespan allowed for user tokens to access the organization's resources. Defaults to two years (2y). Format:<number><unit>where unit ish(hours),d(days),w(weeks),mo(months), ory(years). Example 1mo- 1 month** Decimal values also accepted: 0.5h is half an hour**
Limitation
External links
Output from tests