Skip to content

Commit

Permalink
Switch to integrated Terraform variable validation (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKotowick authored Jul 11, 2024
1 parent f6bba7b commit b04ce2f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
steps:
- name: Generate Matrix
id: matrix
uses: Invicton-Labs/terraform-module-testing/matrix@v0.1.0
uses: Invicton-Labs/terraform-module-testing/matrix@v0.2.0
with:
minimum_tf_version: '0.13.0'
minimum_tf_version: '1.9.0'

- name: Output Matrix
run: |
Expand All @@ -28,23 +28,23 @@ jobs:
steps:
- name: Initialize - Pass
id: init-pass
uses: Invicton-Labs/terraform-module-testing/initialize@v0.1.0
uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0
with:
tf_path: tests/pass
- name: Run Tests - Pass
id: tests-pass
uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.1.0
uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.2.0
with:
tf_path: tests/pass

- name: Initialize - Fail
id: init-fail
uses: Invicton-Labs/terraform-module-testing/initialize@v0.1.0
uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0
with:
tf_path: tests/fail
- name: Run Tests - Fail
id: tests-fail
uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.1.0
uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.2.0
with:
tf_path: tests/fail

Expand All @@ -56,4 +56,4 @@ jobs:
needs: [Test]
steps:
- name: Mark tests as passed
run: echo "🎉"
run: echo "🎉"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Invicton Labs (https://invictonlabs.com)
Copyright (c) 2021-2024 Invicton Labs (https://invictonlabs.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 0 additions & 13 deletions main.tf

This file was deleted.

12 changes: 11 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
output "error_message" {
description = "The value of the `error_message` input variable."
value = var.error_message
}

output "condition" {
description = "The value of the `condition` input variable."
value = var.condition
}

output "checked" {
description = "Whether the condition has been checked (used for assertion dependencies)."
value = data.cloudinit_config.check.rendered == "" ? true : true
value = var.condition == true ? true : true
}
19 changes: 14 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
variable "condition" {
description = "The condition to ensure is `true`."
type = bool
}

variable "error_message" {
description = "The error message to display if the condition evaluates to `false`."
type = string
nullable = false
}

variable "condition" {
description = "The condition to ensure is `true`."
type = bool
validation {
// We have to use var.error_message != null to force the evaluation to wait
// until var.error_message is known. Otherwise, it can fail during the validation
// phase but won't output the proper error message.
// https://github.com/hashicorp/terraform/issues/35397
condition = var.error_message != null && var.condition == true
error_message = var.error_message
}
}
8 changes: 1 addition & 7 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
terraform {
required_version = ">= 0.13.0"
required_providers {
cloudinit = {
source = "hashicorp/cloudinit"
version = ">= 2.3.1"
}
}
required_version = ">= 1.9.0"
}

0 comments on commit b04ce2f

Please sign in to comment.