使用Terraform创建AWS CodePipeline时发生Github存储库webhook错误



在作为CodePipeline的一部分创建Github存储库webhook时,我收到以下错误。

github_repository_webhook.github_hook:正在创建。。。错误:POSThttps://api.github.com/repos/myrepoxx/static-web-example/hooks:404找不到[]

尝试更改URL和存储库,但没有成功

挂钩.tf

resource "aws_codepipeline_webhook" "codepipeline_webhook" {
authentication  = "GITHUB_HMAC"
name            = "codepipeline-webhook"
target_action   = "Source"
target_pipeline = aws_codepipeline.static_web_pipeline.name
authentication_configuration {
secret_token = random_string.github_secret.result
}
filter {
json_path    = "$.ref"
match_equals = "refs/heads/{Branch}"
}
tags = {}
}
resource "github_repository_webhook" "github_hook" {
repository = var.repository_name
events     = ["push"]
configuration {
url          = aws_codepipeline_webhook.codepipeline_webhook.url
insecure_ssl = "0"
content_type = "json"
secret       = random_string.github_secret.result
}
}
resource "random_string" "github_secret" {
length  = 99
special = false
}

变量

variable "env" {
default     = "dev"
}
variable "region" {
default     = "eu-west-1"
}
variable "repository_branch" {
default     = "master"
}
variable "repository_owner" {
default     = "myrepoxx"
}
variable "repository_name" {
default     = "static-web-example"
}
variable "static_web_bucket_name" {
default     = "myrepoxx-static-web-example-bucket"
}
variable "artifacts_bucket_name" {
default     = "myrepoxx-static-web-example-artifacts"
}
variable "github_token" {
}
output "web_public_url" {
value = aws_s3_bucket.static_web_bucket.website_endpoint
}

根据terraform文档,从terraform 0.13开始,github提供程序源应该是integrations/github

terraform {
required_providers {
github = {
source  = "integrations/github"
version = "4.x.x"
}
}
}

然后,如果您需要,您可以将提供者配置为设置您的OAuth/个人访问令牌

provider "github" {
owner = var.repo_owner
token = var.github_token
}

最新更新