bschaatsbergen / terraform-provider-assert

Utility provider that contains functions to assert values and validate your Terraform configurations effectively.

Home Page:https://registry.terraform.io/providers/bschaatsbergen/assert/latest/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Provider: Assert

The Assert Terraform provider is intended for use when writing Terraform tests. It serves as a way to verify that the values in your Terraform configuration meet specific criteria. The provider only contains functions to assert values, and does not manage any resources.

To use provider functions, declare the provider as a required provider in your Terraform configuration:

terraform {
  required_providers {
    assert = {
      source = "bschaatsbergen/assert"
    }
  }
}

Continuous Validation

Simplify continuous validation checks that run as part of your Terraform workflow:

data "http" "terraform_io" {
  url = "https://www.terraform.io"
}

check "health_check" {
  assert {
    condition     = provider::assert::http_success(data.http.terraform_io.status_code)
    error_message = "${data.http.terraform_io.url} returned an unhealthy status code"
  }
}

Terraform Test

Test assertions in your Terraform configuration should be simple and easy to read:

run "ebs_volume_size" {

  command = plan

  assert {
    condition     = provider::assert::between(1, 100, aws_ebs_volume.example.size)
    error_message = "EBS volume size must be between 1 and 100 GiB"
  }
}

Variable Validation

Write simple validation rules for your Terraform variables:

variable "ebs_volume_size" {
  type = number
  validation {
    condition     = provider::assert::between(1, 100, var.ebs_volume_size)
    error_message = "EBS volume size must be between 1 and 100 GiB"
  }
}

License

Mozilla Public License v2.0

About

Utility provider that contains functions to assert values and validate your Terraform configurations effectively.

https://registry.terraform.io/providers/bschaatsbergen/assert/latest/docs

License:Mozilla Public License 2.0


Languages

Language:Go 98.6%Language:Makefile 0.8%Language:HCL 0.5%Language:CSS 0.1%