如何使用上次创建的git标签触发管道(Terraform -AWS CodeCommit)
我想从创建的最后一个git标签(gitlab)中触发AWS中的管道,在我的Terraform模块中,我告诉它从特定的标签中启动管道,但这是否有效,但是是否可以传递动态值?这个想法是用最后一个创建的git标签触发管道。
{
"source" = ["aws.codecommit"]
"detail-type" = ["CodeCommit Repository State Change"]
"resources" = [data.aws_codecommit_xxxxxxxxx]
"detail" = {
"event" = ["referenceCreated", "referenceUpdated"]
"referenceType" = ["tag"]
"referenceName" = [var.repository_tag_version]
}
}
var.repository_tag_version应该是最新的git标签,在Terraform中有一种方法:git describ descript -tags -tags -abbrev = 0以获取最新的?
I want to trigger pipelines in AWS from the last git tag created (Gitlab), in my terraform module I am telling it to fire the pipeline from a specific tag and that is working, but is it possible to pass a dynamic value? The idea is to trigger the pipeline with the last created git tag.
{
"source" = ["aws.codecommit"]
"detail-type" = ["CodeCommit Repository State Change"]
"resources" = [data.aws_codecommit_xxxxxxxxx]
"detail" = {
"event" = ["referenceCreated", "referenceUpdated"]
"referenceType" = ["tag"]
"referenceName" = [var.repository_tag_version]
}
}
var.repository_tag_version should be the latest git tag, there is a way to do this in terraform: git describe --tags --abbrev=0 to get the latest one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是我能够修复它的方式。
1:创建一个bash脚本,在脚本中,您需要执行逻辑以克隆存储库并获得想要获得的标签。 IE:
MAIN.TF中的external_script.sh
:
读取最后一个git标签的值:
现在,该值在data.local_file.read_file_content中,因此事件触发器应该看起来像这样:
“ referenceType” = [referenceType'= [“ tag”]
referencenCename”。 = [{“ prefix”:data.local_file.read_file_content.content}]]
This is how I was able to fix it.
1: Create a bash script, inside the script you need to do logic to clone the repository and get the tag you want to get. i.e:
external_script.sh
In main.tf:
Read the value of the last git tag:
Now, the value is in data.local_file.read_file_content, So the event trigger should looks like this:
"referenceType" = ["tag"]
"referenceName" = [{ "prefix": data.local_file.read_file_content.content }]