Skip to content

Commit

Permalink
feat: add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaatsbergen committed Apr 1, 2024
1 parent 48ad70e commit f088020
Show file tree
Hide file tree
Showing 76 changed files with 793 additions and 176 deletions.
24 changes: 21 additions & 3 deletions docs/functions/between.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::between(1, 10, 5)
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 Example

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

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/contains.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::contains(["a", "b", "c"], "b")
run "check_example_subnet_cidr_block" {
command = plan
assert {
condition = provider::assert::contains(cidrsubnets("10.1.0.0/16", 4, 4, 8, 4), aws_subnet.example.cidr_block)
error_message = "CIDR block is not in the list of allowed subnets"
}
}
```

## Variable Validation Example

```terraform
variable "environment" {
type = string
validation {
condition = provider::assert::contains(["dev", "test", "prod"], var.environment)
error_message = "Environment must be either dev, test, or prod"
}
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/equal.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::equal(1000000, 1000000)
run "number_of_glue_job_workers_is_5" {
command = plan
assert {
condition = provider::assert::equal(aws_glue_job.example.number_of_workers, 5)
error_message = "Number of Glue job workers must be 5"
}
}
```

## Variable Validation Example

```terraform
variable "number_of_glue_job_workers" {
type = number
validation {
condition = provider::assert::equal(var.number_of_glue_job_workers, 5)
error_message = "Number of Glue job workers must be 5"
}
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/false.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::false(false)
run "check_rds_global_cluster_deletion_protection" {
command = plan
assert {
condition = provider::assert::false(aws_rds_global_cluster.example.deletion_protection)
error_message = "Cluster deletion protection must false, this is a dev environment"
}
}
```

## Variable Validation Example

```terraform
variable "rds_global_cluster_deletion_protection" {
type = bool
validation {
condition = provider::assert::false(var.rds_global_cluster_deletion_protection)
error_message = "Cluster deletion protection must false, this is a dev environment"
}
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/greater.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::greater(500, 200)
run "check_aws_db_instance_size" {
command = plan
assert {
condition = provider::assert::greater(aws_db_instance.example.instance_class, 100)
error_message = "DB instance size must be greater than 100"
}
}
```

## Variable Validation Example

```terraform
variable "db_instance_size" {
type = number
validation {
condition = provider::assert::greater(var.db_instance_size, 100)
error_message = "DB instance size must be greater than 100"
}
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/greater_or_equal.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::greater_or_equal(1000000, 1000000)
run "check_aws_db_instance_size" {
command = plan
assert {
condition = provider::assert::greater_or_eqal(aws_db_instance.example.instance_class, 100)
error_message = "DB instance size must be greater than or equal to 100"
}
}
```

## Variable Validation Example

```terraform
variable "db_instance_size" {
type = number
validation {
condition = provider::assert::greater_or_eqal(var.db_instance_size, 100)
error_message = "DB instance size must be greater than or equal to 100"
}
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/http_client_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::http_client_error(400)
run "check_http_client_error" {
command = plan
assert {
condition = provider::assert::http_client_error(data.http.secured.status_code)
error_message = "My secure website must return an HTTP client error status code"
}
}
```

## HTTP GET Example

```terraform
data "http" "secure" {
url = "https://my.secure.website.com"
}
output "is_redirected" {
value = provider::assert::http_client_error(data.http.secure.status_code)
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/http_redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::http_redirect(301)
run "check_http_redirect" {
command = plan
assert {
condition = provider::assert::http_redirect(data.http.hashicorp.status_code)
error_message = "HashiCorp's website must return a 3xx status code, when using HTTP instead of HTTPS"
}
}
```

## HTTP GET Example

```terraform
data "http" "hashicorp" {
url = "https://hashicorp.com"
}
output "is_redirected" {
value = provider::assert::http_redirect(data.http.hashicorp.status_code)
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/http_server_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::http_server_error(504)
run "check_http_server_error" {
command = plan
assert {
condition = provider::assert::http_client_error(data.http.down.status_code)
error_message = "My down website must return an HTTP server error status code"
}
}
```

## HTTP GET Example

```terraform
data "http" "down" {
url = "https://my.down.website.com"
}
output "is_redirected" {
value = provider::assert::http_server_error(data.http.down.status_code)
}
```

Expand Down
16 changes: 11 additions & 5 deletions docs/functions/http_success.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::http_success(200)
run "check_http_success" {
command = plan
assert {
condition = provider::assert::http_success(data.http.hashicorp.status_code)
error_message = "HashiCorp's website must return a 2xx status code"
}
}
```

## HTTP GET request
## HTTP GET Example

```terraform
data "http" "hashicorp" {
url = "https://developer.hashicorp.com"
url = "https://hashicorp.com"
}
output "is_redirected" {
Expand Down
24 changes: 21 additions & 3 deletions docs/functions/less.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::less(100, 200)
run "check_aws_db_instance_size" {
command = plan
assert {
condition = provider::assert::less(aws_db_instance.example.instance_class, 1000)
error_message = "DB instance size must be less than 1000"
}
}
```

## Variable Validation Example

```terraform
variable "db_instance_size" {
type = number
validation {
condition = provider::assert::less(var.db_instance_size, 1000)
error_message = "DB instance size must be less than 1000"
}
}
```

Expand Down
24 changes: 21 additions & 3 deletions docs/functions/less_or_equal.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@ description: |-



## Example Usage
## Terraform Test Example

```terraform
output "test" {
value = provider::assert::less(100, 100)
run "check_aws_db_instance_size" {
command = plan
assert {
condition = provider::assert::less_or_equal(aws_db_instance.example.instance_class, 1000)
error_message = "DB instance size must be less than or equal to 1000"
}
}
```

## Variable Validation Example

```terraform
variable "db_instance_size" {
type = number
validation {
condition = provider::assert::less_or_equal(var.db_instance_size, 1000)
error_message = "DB instance size must be less than or equal to 1000"
}
}
```

Expand Down
Loading

0 comments on commit f088020

Please sign in to comment.