2

I'm in the process of upgrading our version of the Terraform AWS Provider and after fixing/updating every resource and data source which has been deprecated/changed between versions (3.75.2 -> 4.0.0) I'm left with one final error message (Error: a number is required) I can't get to the bottom of because it doesn't give any indication of module/file/resource/line number or anything really to go by.

I get the error on a terraform plan as follows

$ terraform plan
aws_s3_bucket.static_nlb: Refreshing state... [id=<redacted>]
#
#...more resources refreshing state...
#
aws_ssm_parameter.processor_sqs: Refreshing state... [id=/config/scripts/sqs/iam_access_policy]

Error: a number is required

ERRO[0052] Hit multiple errors:
Hit multiple errors:
exit status 1 
$ 

Environment Details:

  • Terraform version: 0.14.11
  • Terraform AWS Provider: 4.0.0 (upgraded from 3.75.2)

Troubleshooting/Things I've Tried

  • Commenting out two of the modules I thought might be responsible and there was no change. I've tried running
  • Running with TF_LOG=DEBUG or TF_LOG=TRACE

I didn't see anything in the output though it was looking for a needle in a haystack. I did try grepping for obvious key words: type, error, number etc.

Its a very large terraform project and I am at a bit of a loss how to proceed with debugging this error

Has anyone seen this before and can suggest what it is/how I might be able to dig further?

2
  • I notice you're using a very old version of Terraform. Trying terraform plan with the very latest version of Terraform might give you a better error message, since I think various bugs that were causing contextless errors have been fixed in the intermediate versions. Even if you're not really to upgrade permanently to a newer Terraform version, just running terraform plan with the latest version shoudn't do any harm as long as you don't apply the plan or run any of the other commands that can modify the Terraform state. Dec 10, 2022 at 0:19
  • Thanks @MartinAtkins. Yep upgrading this project is overdue. I will try run terraform plan with a newer version of terraform and see where that gets me. Dec 11, 2022 at 10:06

1 Answer 1

2

Thanks @Martin Atkins, a big upgrade of terraform and the aws provider appears to have solved the problem.

After upgrading to terraform to 1.3.6 I got a bit more information about the nature of the error. It appears it was related to the object expiry property of s3 bucket object lifecycle policy configuration.

This was also manifesting itself by the object lifecycle property resource "flapping" between, needs creating and needs deleting every terraform run which was the motivation for embarking on this upgrade in the first place.

Upgrading AWS terraform provider to 4.0.8 resolved warnings and state flapping issues.

1
  • The plugin version you refer to seems to be 4.8.0, as version 4.0.8 doesn't exist.
    – Marcus
    Sep 26, 2023 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.