Skip to content

Fix AWS Batch Job Definition EKS Properties Structure #44

@fvazquez20

Description

@fvazquez20

Description

AWS Batch job definition creation fails with multiple "Unsupported attribute" errors when using EKS properties. The module incorrectly accesses attributes from eks_properties.value.pod_properties when they should be accessed directly from eks_properties.value.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

  • Module version [Required]: Latest
  • Terraform version: 1.5.0+
  • Provider version(s): AWS provider 5.0+

Reproduction Code [Required]

Steps to reproduce the behavior:

  1. Create a job definition with EKS properties
  2. Include attributes like dns_policy, host_network, image_pull_secrets, etc.
  3. Run terraform plan or terraform apply

Example configuration:

        }
      }

      dns_policy   = "ClusterFirst"
      host_network = true
      metadata = {
        labels = {
          environment = "test"
        }
      }
    }
  }
}

Expected behavior

A job definition should be created successfully, and all EKS pod properties should be available in the AWS Console under "Pod Properties".

Actual behavior

Terraform fails with errors like:

│ Error: Unsupported attribute
│
│ on .../main.tf line 455, in resource "aws_batch_job_definition" "this":
│ 455: dns_policy = eks_properties.value.pod_properties.dns_policy
│ ├────────────────
│ │ eks_properties.value.pod_properties is object with 1 attribute "containers"
│
│ This object does not have an attribute named "dns_policy".

and similar errors for other attributes (host_network, image_pull_secrets, etc).

Terminal Output Screenshot(s)

Additional context

Root Cause

According to the module's variables.tf, only containers should be inside pod_properties. All other EKS properties (like dns_policy, host_network, image_pull_secrets, init_containers, metadata, service_account_name, share_process_namespace, volumes) should be accessed directly from eks_properties.value.

Required Fixes in main.tf

Example of required changes:

# Before
dns_policy   = eks_properties.value.pod_properties.dns_policy
host_network = eks_properties.value.pod_properties.host_network

# After
dns_policy   = eks_properties.value.dns_policy
host_network = eks_properties.value.host_network

And similarly for all other attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions