如何避免Github repo URL中的双斜杠



我正在尝试创建带有标签过滤器的AWS Codepipeline webhook,并根据terraform文档通过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)
}
}

使用terraform的gh_url输出进行编辑:我正在获取Github中的有效负载url。似乎我不必创建Github webhook,因为已经有了一个,但不知道是否只创建过滤器会允许我只从标签触发管道

不幸的是,我得到了错误:

错误:POSThttps://api.github.com/repos//org_name/repo_name/hooks:404找不到[]

不知道我为什么在上面的URL中得到//。有谁知道如何做到这一点吗?

您缺少配置github提供程序

provider "github" {
token = "secret"
owner = "owner"
}

同样对于存储库,您只需要指定项目

resource "github_repository_webhook" "github_hook" {
repository = "repo_name"
...
}

相关内容

  • 没有找到相关文章

最新更新