简体   繁体   中英

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.

Here is a link to the Terraform docs:

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

Is there another way to possibly enable this feature via Terraform?

I can create a CloudWatch Event to capture CodeBuild events but that doesn't give me the full logs.

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.

The Cloudwatch log Log Group will be created with the following format: 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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