Introduction
When managing AWS Glue Streaming Jobs through Terraform, users may configure a custom timeout for their jobs. However, historically, once a timeout value was set, reverting it back to the default unlimited (null) state was not supported. This resulted in Terraform being unable to clear the timeout configuration, leading to drift and configuration mismatches between Terraform state and AWS.
Problem
Users managing AWS Glue streaming jobs via Terraform observed the following behavior:
-
Creating a job without specifying a timeout results in:
Terraform state showing
timeout = 0AWS CLI showing
None(unlimited)
After setting a timeout, for example
timeout = 500, the value updates successfully in AWS.-
Attempting to revert the timeout to unlimited fails:
timeout = 0→ Terraform error:Error: expected timeout to be at least (1), got 0Removing the timeout argument or setting it to
nullshows no diff in plan, and AWS job does not update.
-
AWS CLI also prevented clearing the timeout:
Setting
Timeout = 0→ parameter validation errorSending an empty update request →
InvalidInputException: Command should not be null
From the AWS Console, users could clear the timeout manually, but Terraform and AWS CLI lacked support for doing the same.
Prerequisites
AWS Glue Streaming ETL Job
Terraform AWS Provider (affected versions before 6.20.0)
Terraform CLI
Cause
In earlier versions of the AWS Provider ( Till 6.19.0 ) , the timeout argument for aws_glue_job enforced a validation rule requiring a minimum value of 1, making it impossible to set the value back to 0 to represent "unlimited".
Solutions:
The issue has been resolved in the AWS Provider version 6.20.0.
Fix Introduced:
timeout = 0is now allowed for Apache Spark Streaming ETL jobs.Setting
timeout = 0now correctly configures the Glue job to have no timeout (unlimited).Terraform will properly update the Glue job and reflect the change in state and AWS.
Example Updated Configuration
resource "aws_glue_job" "streaming_job" {
name = "sample-streaming-job-repro"
role_arn = aws_iam_role.glue_job_role.arn
glue_version = "5.0"
timeout = 0 ## Allowed from provider version 6.20.0+
number_of_workers = 2
max_retries = 0
worker_type = "G.1X"
execution_class = "STANDARD"