-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Labels
Description
Dear Terraform Compliance team, thanks for making this useful tool!
Description
When writing tests which compare a version string with a major and minor part, Terraform Compliance appears to trim any trailing zeros from the minor part if it is a multiple of ten. For example, "1.30" is rounded to 1.3.
This means these tests will error even when the actual resource version matches the value provided in the test.
To Reproduce
Feature File:
Feature: Check the versions are correct
Scenario: Example compliance test
Given I have local_file resource configured
When its name is foo
Then it must have content
And its value must be "1.30"
Plan File:
terraform {
required_version = ">= 1.9.6"
}
terraform {
required_providers {
local = {
source = "hashicorp/local"
version = "2.5.2"
}
}
}
resource "local_file" "foo" {
content = "1.30"
filename = "${path.module}/foo.bar"
}
Used terraform-compliance
Parameters:
terraform-compliance -f features/ -p plan.json
Running via Docker:
Yes.
% docker version
Client:
Cloud integration: v1.0.35+desktop.4
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:28:49 2023
OS/Arch: darwin/amd64
Context: desktop-linux
Error Output:
% terraform-compliance -f features/ -p plan.json
terraform-compliance v1.3.49 initiated
🚩 Features : /target/features/
🚩 Plan File : /target/plan.json
🚩 Running tests. 🎉
Feature: Check the versions are correct # /target/features/version.feature
Scenario: Example compliance test
Given I have local_file resource configured
When its name is foo
Then it must have content
Failure: content property in local_file.foo resource does not match with ^1\.30$ case insensitive regex. It is set to 1.3.
And its value must be "1.30"
Failure:
1 features (0 passed, 1 failed)
1 scenarios (0 passed, 1 failed)
4 steps (3 passed, 1 failed)
Run 1738057003 finished within a moment
Expected Behavior:
To be able to test that a Terraform resource which returns a version string matches an expected version.
Tested Versions:
- terraform-compliance version:
v1.3.49
- terraform version:
v1.9.6
Additional Context:
I originally came across this issue with AWS EKS cluster Kubernetes versions.