-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempting to test terraform resource property/attribute is set to particular value #120
Comments
Hi @TrickMcCarthy, Thanks for reporting this! We will improve the step that When I {operator} it` where we only support |
Hello @TrickMcCarthy, terraform-compliance Feature: Test for https://github.com/eerkunt/terraform-compliance/issues/120
Scenario: Ensure backup retention period is defined
Given I have aws_rds_cluster defined
Then it must contain backup_retention_period
And its value must be greater than 15 |
Could you please try and let me know if this works for you with |
Hi Eerkunt, It's working now thank you for the addition. Negative and Positive test results below. Observation: It seems a long winded way to run terraform-compliance to have to produce the plan and then convert it. I preferred passing in the location of the tf files and having this all done in the background. I see this as a deterrent for usability. Please consider making this unnecessary by going back to original method of passing the terraform module folder and performing the json conversion in the background. Perhaps using terraform go library or https://github.com/kvz/json2hcl
Running Negative test
1 features (0 passed, 1 failed) Running Positive Test
1 features (1 passed) |
Hello @TrickMcCarthy, Thanks for trying out! Unfortunately, there are many reasons why E.g. you may read a value from Having this kind of functionality would require not only lexing HCL2 and implement ALL interpolations that terraform has already, but also fetching dynamic values based on specific resource types. This was a general problem, not only Due to this problem - which is not the only one, tools that are dealing with Unfortunately, there is no plan to process HCL2 directly in the roadmap for now. |
Closing the issue, since it is fixed already. Thanks again! |
I am attempting to validate that resource attribute values are in acceptable range or set to particular value, but there is no step to support this use case. How can the below type of feature file be written?
https://www.terraform.io/docs/providers/aws/r/rds_cluster.html
So I should be able to verify that the value is being set to specific or some range, for any of the resource attributes below.(Same for any other terraform resource)
resource "aws_rds_cluster" "default" {
cluster_identifier = "aurora-cluster-demo"
engine = "aurora-mysql"
engine_version = "5.7.mysql_aurora.2.03.2"
availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"]
database_name = "mydb"
master_username = "foo"
master_password = "bar"
backup_retention_period = 5
preferred_backup_window = "07:00-09:00"
}
Scenario Outline: Retention Period defined
Given I have aws_rds_cluster defined
Then it must contain <retention_rules>
Then its value must be greater than 15
The text was updated successfully, but these errors were encountered: