Loading...
Loading...
### Terraform Version ```shell Terraform v1.13.4 on darwin_arm64 + provider registry.terraform.io/hashicorp/aws v6.17.0 + provider registry.terraform.io/hashicorp/http v3.5.0 + provider registry.terraform.io/hashicorp/local v2.5.3 ``` ### Terraform Configuration Files a.tf ``` data "aws_caller_identity" "current" {} resource "aws_s3_bucket" "this" {} ``` a.tftest.hcl ``` variables { account_id = data.aws_caller_identity.current.account_id } run "test_s3_bucket_name" { command = apply assert { condition = aws_s3_bucket.this.bucket != var.account_id error_message = "S3 Bucket name not matching account id" } } ``` ### Debug Output Probably not relevant ### Expected Behavior 1.12.0 fails test: ``` terraform test -verbose -junit-xml=test.xml a.tftest.hcl... in progress run "test_s3_bucket_name"... fail ╷ │ Error: Invalid reference │ │ on a.tftest.hcl line 2, in variables: │ 2: account_id = data.aws_caller_identity.current.account_id │ │ You can only reference global variables within the test file variables block. ╵ a.tftest.hcl... tearing down a.tftest.hcl... fail Failure! 0 passed, 1 failed ``` Generated junit-xml contains error as expected: ``` <![CDATA[ Error: Invalid reference on a.tftest.hcl line 2, in variables: 2: account_id = data.aws_caller_identity.current.account_id You can only reference global variables within the test file variables block. ]]> </testsuites ``` ### Actual Behavior But since version 1.13.0 it behaves differently. Tested on 1.13.4 ``` terraform test -verbose -junit-xml=test.xml a.tftest.hcl... in progress run "test_s3_bucket_name"... skip a.tftest.hcl... tearing down a.tftest.hcl... fail ╷ │ Error: Invalid reference │ │ on a.tftest.hcl line 2, in variables: │ 2: account_id = data.aws_caller_identity.current.account_id │ │ You can only reference run blocks and variables from within Terraform Test files. ╵ Failure! 0 passed, 0 failed, 1 skipped. ``` unit xml contains no error: ``` </testsuites ``` Problem is with automated test in pipelines this can be easily missed as failure. I would expect it to behave like prior version 1.12.0 and before. ### Steps to Reproduce terraform test with my provided test "files" ### Additional Context _No response_ ### References _No response_ ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.