我们升级为使用integrations/github
提供程序源,并且自从尝试使用 Terraform 创建 github_repository_webhook 时开始收到 404。我相信我们拥有基于文档所需的所有必要部分,但日志中的 API uri 缺少 org. 注意:真实的组织和回购名称已被编辑。
主文件
resource "aws_codepipeline_webhook" "codepipeline_webhook" {
name = "test-github-webhook"
authentication = "GITHUB_HMAC"
target_action = "CC"
target_pipeline = aws_codepipeline.pipeline.name
authentication_configuration {
secret_token = data.aws_secretsmanager_secret_version.github_token.secret_string
}
filter {
json_path = "$.ref"
match_equals = "refs/heads/{Branch}"
}
tags = merge(var.tags, {
Name = "test-github-webhook"
})
}
# Wire the CodePipeline webhook into a GitHub repository.
resource "github_repository_webhook" "github_webhook" {
repository = "my_repo"
configuration {
url = aws_codepipeline_webhook.codepipeline_webhook.url
content_type = "json"
insecure_ssl = true
secret = data.aws_secretsmanager_secret_version.github_token.secret_string
}
events = ["push"]
}
后端.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "3.65.0"
}
github = {
source = "integrations/github"
version = "~> 4.0"
}
}
}
provider "github" {
token = data.aws_secretsmanager_secret_version.github_token.secret_string
owner = "my_org"
base_url = "https://github.com/my_org/" # we have github enterprise
}
创建时出错:
Error: POST https://api.github.com/repos//my_repo/hooks: 404 Not Found []
请注意,该 org 完全从 URL 中丢失。我也尝试在 github_repository_webhook 资源中包含组织名称,但 url 仍然带有双斜杠和 404:
Error: POST https://api.github.com/repos//my_org/my_repo/hooks: 404 Not Found []
当我完全删除提供程序源和版本时,terraform 会回退到hashicorp/terraform
源并且 webhook 创建没有任何问题。有没有其他人遇到过这个问题?