.tf
file:
module "vnet" {
source = "Azure/vnet/azurerm"
version = "2.5.0"
vnet_name = "vnet1"
resource_group_name = "rg1"
address_space = ["10.0.0.0/16"]
subnet_prefixes = ["10.0.1.0/24"]
subnet_names = ["subnet1"]
tags = {
environment = "dev"
}
}
subnet_id = module.vnet.vnet_subnets[0]
outputs.tf
:output "virtual_network_name" {
description = "Virtual Network Name"
value = module.vnet.vnet_name
}
terraform init
downloads the modules into .terraform directory prior to downloading the provider plugins.
terraform state list
to identify the resource that you wish to taint.terraform taint
command e.g. terraform taint module.vnet.azurerm_subnet.subnet[2]
and then terraform apply
. At this point on the next terraform apply the tainted resource will be recreated.Note: HashiCorp now recommend the use of terraform apply -replace='module.vnet.azurerm_subnet.subnet[2]'
instead of the [terraform taint](https://www.terraform.io/cli/commands/taint)
command.
modules\module_name
.main.tf
, outputs.tf
, variables.tf
and versions.tf
files.README.md
.module "resource_group" {
source = "./modules/resource_group"
location = "uksouth"
resource_group_name = "rg1"
}
output "resource_group_id" {
description = "resource group id"
value = azurerm_resource_group.resource_group.id
}
output "resource_group_id" {
description = "resource group id"
value = module.resource_group.resource_group_id
}
terraform get
will get the modules and update the .terraform/modules/module_name/modules.json
file, it does not initialize the backend.terraform get
command.terraform get
command.Readme.md
, variables.tf
, versions.tf
and outputs.tf
it will populate the Readme, Inputs, Outputs and Dependency tabs respectively.module "staticwebsitepublic" {
source = "richbjhudson/staticwebsitepublic/azurerm"
version = "1.0.0"
# insert the 8 required variables here
}
sources
argument assumes prefix “https://registry.terraform.io/modules/”module "s3-bucket" {
source = "app.terraform.io/richbjhudson/s3-bucket/aws"
version = "2.13.0"
# insert required variables here
}
Example of using GitHub to store module: source = "github.com/richbjhudson/terraform-azurerm-staticwebsitepublic"
.
Example of using GitHub to store module - with SSH connectivity: source = "git@github.com:richbjhudson/terraform-azurerm-staticwebsitepublic.git"
.
Example of using GitHub to store module and selecting a specific release: source = "git::https://github.com/stacksimplify/terraform-azurerm-staticwebsitepublic.git?ref=1.0.0"
.