Skip to content

Commit 55c9560

Browse files
committed
Add precondition for expired gitlab token
1 parent 3259da2 commit 55c9560

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

terraform/modules/spack/gitlab_webhooks.tf

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,23 @@ data "gitlab_user" "spackbot" {
2222
username = "spackbot"
2323
}
2424

25+
locals {
26+
webhook_handler_token_expires_at = "2024-12-03"
27+
}
28+
2529
resource "gitlab_personal_access_token" "webhook_handler" {
2630
user_id = data.gitlab_user.spackbot.id
2731
name = "Webhook handler token"
28-
# TODO: How to deal with this expiring
29-
expires_at = "2024-12-03"
32+
expires_at = local.webhook_handler_token_expires_at
3033

3134
scopes = ["read_api", "read_repository"]
35+
36+
lifecycle {
37+
precondition {
38+
condition = timecmp(timestamp(), "${local.webhook_handler_token_expires_at}T00:00:00Z") == -1
39+
error_message = "The token has expired. Please update the expires_at date."
40+
}
41+
}
3242
}
3343

3444
resource "random_password" "webhook_handler" {

0 commit comments

Comments
 (0)