从 Terraform 创建时,AWS 中的 CodePipeline 会自动触发

发布于 2025-01-09 07:49:15 字数 486 浏览 1 评论 0原文

作为我的要求的一部分,我尝试从 Terraform 创建 AWS CodePipeline 并在创建后手动触发 CodePipeline。但不幸的是,CodePipeline 一旦从 Terraform 创建后就会自动触发,

我正在尝试找到一种方法来阻止 Codepipeline 在从 Terraform 部署后自动触发。 我试图执行以下两种方法之一,但我没有找到任何相关的内容。

  1. 查找任何将自动触发设置为 false 的参数。
  2. 或者启用源和第一阶段之间的“DisableInboundStageTransitions”。因此,即使源已启动,管道阶段也不会运行。

我看到“DisableInboundStageTransitions”在 CloudFormation 中可用,但在 Terraform 中不可用。

如果有人能让我知道是否可以从 Terraform 执行上述操作,那就太好了? 有没有任何解决方法可以实现相同的目标?

提前致谢。

As part of my requirement I am trying to create a AWS CodePipeline from Terraform and Trigger the CodePipeline Manually once created. But Unfortunately the CodePipeline is getting triggered automatically once created from Terraform

I am Trying to find a way to stop the Codepipeline from triggering automatically as soon as it is deployed from Terraform.
I was trying to do one of the below 2 methods, But I did not find anything relevant for the same.

  1. Find any Parameter which sets the auto trigger to false.
  2. Or Enable the "DisableInboundStageTransitions" between the Source and the First Stage. So the pipeline stage's will not run even if the source has started.

I see "DisableInboundStageTransitions" is available in CloudFormation but not in Terraform.

It Would be really great if someone can let me know that is it even possible to do the above from Terraform?
Is there any workaround to Achieve the same?

Thanks in Advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

抚你发端 2025-01-16 07:49:15

您可以使用 local-exec 解决此问题terraform 中的配置程序 在管道创建后立即停止执行。 terraform 的用户还必须安装并配置 awscli,并安装 jq

resource "aws_codepipeline" "my_pipeline" {
  name     = "my-deploy"
  ...etc...

  provisioner "local-exec" {
    command = <<EOT
aws codepipeline stop-pipeline-execution \
  --pipeline-name ${aws_codepipeline.my_pipeline.name} \
  --pipeline-execution-id $( \
    aws codepipeline list-pipeline-executions \
      --pipeline-name ${aws_codepipeline.my_pipeline.name} \
    | jq -r '.pipelineExecutionSummaries[].pipelineExecutionId' \
  )
EOT
  }
}

上面的脚本是仓促构建的,如果出现以下情况,可能需要进行调整:

  • 没有执行可以停止。
  • 有不止一次执行需要停止。
  • 有一次执行,但其状态不是InProgress
  • 停止执行失败。

希望这有帮助!

You can solve this using the local-exec provisioner in terraform to stop the execution immediately after pipeline creation. The user of terraform must also have awscli installed and configured, and jq installed.

resource "aws_codepipeline" "my_pipeline" {
  name     = "my-deploy"
  ...etc...

  provisioner "local-exec" {
    command = <<EOT
aws codepipeline stop-pipeline-execution \
  --pipeline-name ${aws_codepipeline.my_pipeline.name} \
  --pipeline-execution-id $( \
    aws codepipeline list-pipeline-executions \
      --pipeline-name ${aws_codepipeline.my_pipeline.name} \
    | jq -r '.pipelineExecutionSummaries[].pipelineExecutionId' \
  )
EOT
  }
}

The script above was hastily built and may have to be adjusted if;

  • There is no execution to stop.
  • There is more than one execution to stop.
  • There is one execution but its status is not InProgress.
  • Stopping the execution fails.

Hope this helps!

彩扇题诗 2025-01-16 07:49:15

DetectChanges 属性可以在代码管道资源块中使用,它对我来说很有效。确保您提供 true 或 false 值。您可以在下面找到此属性的图像表示。

点击此处查看图片

DetectChanges attribute can be utilized within the code pipeline resource block, and it has been effective for me. Ensure that you provide either a true or false value. You can find an image representation of this attribute below.

Click here to see image

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文