Skip to content

AWS Batch Job Definition: Provided name is not supported pattern[a-zA-Z_0-9-]{1,128} #2124

@kmingwww

Description

@kmingwww

Issue

When importing AWS batch, encounter the following error:

2026/01/15 16:45:59 reading Batch Job Definition (xxxx-job:0x14005b345e4): operation error Batch: DescribeJobDefinitions, https response error StatusCode: 400, RequestID: ca0ef118-8688-4dd2-b02b-87e69bd66493, ClientException: Provided name xxxx-job:0x14005b345e4 is not supported pattern[a-zA-Z_0-9-]{1,128}
2026/01/15 16:45:59 WARN: Fail read resource from provider, wait 300ms before retry
2026-01-15T16:46:01.029+0800 [ERROR] plugin.terraform-provider-aws_v5.100.0_x5: Response contains error diagnostic: tf_rpc=ReadResource diagnostic_severity=ERROR tf_proto_version=5.8 tf_req_id=a7632268-39fc-b78f-1271-15a92b823cad tf_resource_type=aws_batch_job_definition @caller=github.com/hashicorp/terraform-plugin-go@v0.26.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto diagnostic_detail="" diagnostic_summary="reading Batch Job Definition (xxxx-job:0x14005b345e8): operation error Batch: DescribeJobDefinitions, https response error StatusCode: 400, RequestID: 0d936ff4-9fd3-4ee4-ba8c-d8dece461508, ClientException: Provided name xxxx-job:0x14005b345e8 is not supported pattern[a-zA-Z_0-9-]{1,128}" tf_provider_addr=registry.terraform.io/hashicorp/aws timestamp="2026-01-15T16:46:01.029+0800"

The provided name is returning hexadecimal representation instead of string example: xxxx-job:0x14005b345e4.

Root Cause

jobDefinitionName := StringValue(jobDefinition.JobDefinitionName) + ":" + fmt.Sprint(jobDefinition.Revision)

  • jobDefinition.Revision is not a simple string or integer. In the AWS SDK for Go, the Revision field within the JobDefinition struct is likely a pointer to an integer (*int64) or another complex type. It's not just a simple value.

  • fmt.Sprint()'s default behavior for pointers. When you use fmt.Sprint() on a pointer or a struct that doesn't have a specific String() method defined, Go's default behavior is to print the memory address where that object is stored. Memory addresses are conventionally represented in hexadecimal format.

Fix

// Incorrect (what's currently there)
jobDefinitionName := StringValue(jobDefinition.JobDefinitionName) + ":" + fmt.Sprint(jobDefinition.Revision)

// Corrected version
jobDefinitionName := StringValue(jobDefinition.JobDefinitionName) + ":" + fmt.Sprint(*jobDefinition.Revision) // Note the *

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