Certainly! The rotation_configuration block in the gitlab_group_access_token Terraform resource is used to configure automatic rotation of the group access token, which helps improve security by periodically renewing the token.
Here’s a detailed explanation and example of how to correctly set up the rotation_configuration schema for the gitlab_group_access_token resource:
gitlab_group_access_token resource overview
This resource creates a personal access token scoped to a GitLab group, which can be used for automation or CI/CD pipelines.
rotation_configuration block
The rotation_configuration block allows you to specify how and when the token should be rotated automatically.
Supported attributes inside rotation_configuration:
- enabled (bool) — Whether token rotation is enabled.
- rotation_interval (string) — The interval at which the token should be rotated, expressed as a duration string (e.g.,
"24h", "168h" for 7 days).
- rotation_grace_period (string) — The grace period before the token expires during which the rotation should happen, also a duration string.
- rotation_expiration (string) — The total expiration time of the token, after which it will no longer be valid.
Example Terraform configuration
resource "gitlab_group_access_token" "example" {
group = "my-group"
name = "example-token"
scopes = ["api", "read_repository"]
rotation_configuration {
enabled = true
rotation_interval = "168h" # Rotate every 7 days
rotation_grace_period = "24h" # Start rotation 1 day before expiration
rotation_expiration = "720h" # Token expires after 30 days
}
}
Explanation
enabled = true — Enables automatic rotation.
rotation_interval = "168h" — The token will be rotated every 7 days.
rotation_grace_period = "24h" — Rotation will start 24 hours before the token expires.
rotation_expiration = "720h" — The token will expire after 30 days (720 hours).
Notes
- Duration strings must be in the format accepted by Terraform, typically a number followed by a unit (
h for hours, m for minutes, s for seconds).
- The rotation mechanism will create a new token and revoke the old one according to the schedule.
- Make sure your GitLab instance supports token rotation for group access tokens (this is a relatively new feature and may require a certain GitLab version).
If you want, I can also help you with a full example including provider setup or troubleshooting any errors you encounter!