Skip to content

An opinionated example of how to test Terraform configurations.

License

Notifications You must be signed in to change notification settings

christosgalano/terraform-testing-example

Repository files navigation

terraform-testing-example

An opinionated example of how to test Terraform configurations. It includes:

  • Terraform Configurations: A simple architecture that creates an Azure Web App, Key Vault, and associated resources. This demonstrates how to structure and organize Terraform code.
  • Tests: Contract and integration tests that ensure the Terraform code behaves as expected. These tests are located in the tests directory and provide examples of how to write and structure tests for Terraform code.
  • GitHub Workflows: Automated workflows for continuous integration and deployment. These workflows, located in the .github/workflows directory, automate the process of scanning the code for issues, running the tests, and deploying the infrastructure.
  • Configuration Files: These files configure various tools used in the repository, such as tflint, trivy, checkov, and terraform-docs. They demonstrate how to set up and configure these tools for use with Terraform.

This repository follows best practices for Terraform development and uses GitHub workflows for automation. It serves as a practical example of how to test and deploy Terraform code.

ci

deploy

Requirements

Name Version
terraform >= 1.8
azurerm ~> 3.0

Providers

Name Version
azurerm ~> 3.0

Modules

No modules.

Resources

Name Type
azurerm_key_vault.this resource
azurerm_linux_web_app.this resource
azurerm_private_dns_zone.vault resource
azurerm_private_dns_zone_virtual_network_link.vault resource
azurerm_private_endpoint.vault resource
azurerm_resource_group.this resource
azurerm_service_plan.this resource
azurerm_subnet.app_service resource
azurerm_subnet.private_endpoint resource
azurerm_virtual_network.this resource
azurerm_client_config.current data source

Inputs

Name Description Type Default Required
app_service_delegated_subnet Configuration for the App Service delegated subnet.
object({
name = string
address_prefix = string
})
n/a yes
app_service_plan Configuration for the app service plan.
object({
name = string
sku = string
})
n/a yes
key_vault Configuration for the key vault.
object({
name = string
sku = string
private_endpoint_name = string
dns_zone_name = optional(string, "privatelink.vaultcore.azure.net")
})
n/a yes
location Location of the resources. string n/a yes
private_endpoint_subnet Configuration for the private endpoint subnet.
object({
name = string
address_prefix = string
})
n/a yes
resource_group_name Name of the resource group. string n/a yes
virtual_network Configuration for the virtual network.
object({
name = string
address_space = list(string)
})
n/a yes
web_app Configuration for the web app.
object({
name = string
docker_image_name = string
docker_registry_url = string
})
n/a yes

Outputs

Name Description
app_service_plan_id The ID of the app service plan.
app_service_subnet_id The ID of the app service subnet.
key_vault_id The ID of the key vault.
key_vault_uri The URI of the key vault.
private_dns_zone_vault_id The ID of the private DNS zone for the vault.
private_endpoint_subnet_id The ID of the private endpoint subnet.
private_endpoint_vault_id The ID of the private endpoint for the vault.
resource_group_id The ID of the resource group.
virtual_network_id The ID of the virtual network.
web_app_hostname The hostname of the web app.
web_app_id The ID of the web app.

About

An opinionated example of how to test Terraform configurations.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages