我正在尝试使用标签过滤器创建 AWS Codepipeline webhook,并根据 Terraform docs 通过 terraform 将其插入现有存储库 webhook
我使用过的代码:
resource "aws_codepipeline_webhook" "pprod_webhook" {
name = "${var.client_code}-${var.environment}-pprod-hook"
authentication = "GITHUB_HMAC"
target_action = "Source"
target_pipeline = aws_codepipeline.cd.name
authentication_configuration {
secret_token = data.aws_ssm_parameter.github_token.value
}
filter {
json_path = "$.ref_type"
match_equals = "tag"
}
}
resource "github_repository_webhook" "github_hook" {
repository = "org_name/repo_name"
configuration {
url = aws_codepipeline_webhook.pprod_webhook.url
content_type = "json"
insecure_ssl = false
secret = data.aws_ssm_parameter.webhook_secret.value
}
active = true
events = ["create"]
}
编辑 terraform plan
:An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
~ update in-place
Terraform will perform the following actions:
# module.codepipeline.github_repository_webhook.github_hook will be created
+ resource "github_repository_webhook" "github_hook" {
+ active = true
+ etag = (known after apply)
+ events = [
+ "create",
]
+ id = (known after apply)
+ repository = "org_name/repo_name"
+ url = (known after apply)
+ configuration {
+ content_type = "json"
+ insecure_ssl = false
+ secret = (sensitive value)
+ url = (sensitive value)
}
}
编辑 gh_url
terraform 的输出:我得到了 Github 中的有效载荷 url。似乎我不必创建 Github webhook,因为一个已经到位,但不知道是否仅创建过滤器将允许我仅从标签触发管道不幸的是我收到错误:
Error: POST https://api.github.com/repos//org_name/repo_name/hooks: 404 Not Found []
不知道为什么我会收到
//
在上面的网址中。有没有人知道如何使这项工作?
最佳答案
您缺少配置 github 提供程序
provider "github" {
token = "secret"
owner = "owner"
}
同样对于存储库,您只需指定项目resource "github_repository_webhook" "github_hook" {
repository = "repo_name"
...
}
关于github - 如何避免 Github repo URL 中的双斜杠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65147393/