Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add precondition for expired gitlab token #836

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
}
}
Comment on lines +36 to +41
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, although I'm concerned at what happens when encounter this expiration date. The terraform plan/apply will fail loudy about it, but besides that how would we know? Let's say if we haven't run terraform plan/apply for a while during the expiration date, would we just be relying on sentry at that point?

This is sort of secondary to this PR, which I think looks good itself, but just thought I'd raise this question.

}

resource "random_password" "webhook_handler" {
Expand Down