Skip to content

Commit

Permalink
Add precondition for expired gitlab token
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandenburgh committed May 8, 2024
1 parent 3259da2 commit e4c2fd1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions terraform/modules/spack/gitlab_webhooks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ data "gitlab_user" "spackbot" {
username = "spackbot"
}

locals {
webhook_handler_token_expires_at = "2024-12-03"
}

resource "gitlab_personal_access_token" "webhook_handler" {
user_id = data.gitlab_user.spackbot.id
name = "Webhook handler token"
# TODO: How to deal with this expiring
expires_at = "2024-12-03"
user_id = data.gitlab_user.spackbot.id
name = "Webhook handler token"
expires_at = local.webhook_handler_token_expires_at

scopes = ["read_api", "read_repository"]

lifecycle {
precondition {
condition = timecmp(timestamp(), "${local.webhook_handler_token_expires_at}T00:00:00Z") == -1
error_message = "The token has expired. Please update the expires_at date."
}
}
}

resource "random_password" "webhook_handler" {
Expand Down

0 comments on commit e4c2fd1

Please sign in to comment.