Terraform-provider-aws: Add support for "logConfiguration" in Batch "job-definition"

Created on 8 Oct 2020  ·  6Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Allow to set logConfiguration section in Batch job definition.

New or Affected Resource(s)

  • aws_batch_job_definition

Potential Terraform Configuration

resource "aws_batch_job_definition" "job_definition" {
  name = "${var.job_definition_name}"
  type = "container"

  container_properties = "${data.template_file.job_definition.rendered}"

  timeout = {
    attempt_duration_seconds = "${var.attempt_duration_seconds}"
  }

  retry_strategy = {
    attempts = 2
  }

  log_configuration": {
    log_driver: "awslogs"
    "options": {
       "awslogs-region": "${var.region}", 
       "awslogs-group": "${var.group_name}",
    },
  }
}

References

  • https://aws.amazon.com/blogs/compute/custom-logging-with-aws-batch/

  • https://docs.aws.amazon.com/cli/latest/reference/batch/register-job-definition.html
  • enhancement servicbatch

    Most helpful comment

    @philnichol it works with the newest v3.10.0 release :) I just tested it with logConfiguration inside container_properties like in your example.

    All 6 comments

    To match the API I guess this could go within container_properties eg:

    resource "aws_batch_job_definition" "test" {
      name = "tf_test_batch_job_definition"
      type = "container"
    
      container_properties = <<CONTAINER_PROPERTIES
    {
        "command": ["ls", "-la"],
        "image": "busybox",
        "memory": 1024,
        "vcpus": 1,
        "logConfiguration": {
            "logDriver": "awslogs",
            "options": {
                "awslogs-group": "example"
            }
        }
    }
    CONTAINER_PROPERTIES
    }
    

    Weirdly when testing locally putting logConfiguration within the container_properties works when I compile the provider with the latest code, but ignores logConfiguration when I use version 3.8.0/3.9.0. Guessing some change that hasn't been released yet fixes this? Couldn't figure out which one though

    @philnichol it works with the newest v3.10.0 release :) I just tested it with logConfiguration inside container_properties like in your example.

    Hi folks 👋 For clarity here, this is one of the places in the Terraform AWS Provider where it will automatically start working with AWS Go SDK updates we perform each week. If something is not working on version 3.10.0 or later of the Terraform AWS Provider, please reach out. 👍

    Thanks @bflad, Is there any way to use it with version 2.7 and TF 0.11?

    @shlomi-viz not in an officially supported release, please see the backport policy in our FAQ. You can potentially pull the code from the release/2.x branch, update the AWS Go SDK (go get github.com/aws/[email protected]), custom build the provider (go build), and point Terraform to the custom version of the provider (the Terraform 0.11 documentation is no longer available on terraform.io, but it amounts to overwriting the existing provider binary or using the plugin cache directory), however the maintainers cannot provide additional assistance if you go that route.

    I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

    If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

    Was this page helpful?
    0 / 5 - 0 ratings