简体   繁体   English

使用Terraform启用AWS CodeBuild将日志推送到CloudWatch

[英]Use Terraform to enabled AWS CodeBuild to push logs to CloudWatch

AWS CodeBuild has an option in the UI to upload build output logs to CloudWatch and/or publish the logs to S3 but I do not see an option in Terraform to enable this feature through the "aws_codebuild_project" resource. AWS CodeBuild在UI中有一个选项,可以将构建输出日志上传到CloudWatch和/或将日志发布到S3,但我没有在Terraform中看到通过“aws_codebuild_project”资源启用此功能的选项。

Here is a link to the Terraform docs: 以下是Terraform文档的链接:

https://www.terraform.io/docs/providers/aws/r/codebuild_project.html https://www.terraform.io/docs/providers/aws/r/codebuild_project.html

Is there another way to possibly enable this feature via Terraform? 有没有其他方法可以通过Terraform启用此功能?

I can create a CloudWatch Event to capture CodeBuild events but that doesn't give me the full logs. 我可以创建一个CloudWatch事件来捕获CodeBuild事件,但这不会给我完整的日志。

So even thought the Terraform documentation does not specify support for enabling CloudWatch logs for CodeBuild jobs, if you create a CodeBuild job with the AWS CodeBuild Project resource it will by default enable that checkbox for you, at least as of the date of this answer. 因此,即使Terraform文档没有指定为CodeBuild作业启用CloudWatch日志的支持,如果您使用AWS CodeBuild项目资源创建CodeBuild作业,默认情况下它将为您启用该复选框,至少截至此答案的日期。

The Cloudwatch log Log Group will be created with the following format: aws/codebuild/codebuild_project_name 将使用以下格式创建Cloudwatch日志日志组:aws / codebuild / codebuild_project_name

There is an open PR for a Github issue to enable CodeBuild CloudWatch logs, so hopefully we will be able to use the following config soon: Github 问题有一个开放的PR来启用CodeBuild CloudWatch日志,所以希望我们能够尽快使用以下配置:

logs_config {
  cloudwatch_logs {
    status = "ENABLED|DISABLED"
    group_name = "..."
    stream_name = "..."
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM