Changed resource names to snake case

This commit is contained in:
Tom Archer 2022-08-29 18:16:52 -07:00
parent 85f9e9a803
commit 71e54587eb
2 changed files with 18 additions and 18 deletions

View File

@ -8,7 +8,7 @@ resource "azurerm_resource_group" "rg" {
} }
# Create virtual network # Create virtual network
resource "azurerm_virtual_network" "myterraformnetwork" { resource "azurerm_virtual_network" "my_terraform_network" {
name = "myVnet" name = "myVnet"
address_space = ["10.0.0.0/16"] address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.rg.location location = azurerm_resource_group.rg.location
@ -16,15 +16,15 @@ resource "azurerm_virtual_network" "myterraformnetwork" {
} }
# Create subnet # Create subnet
resource "azurerm_subnet" "myterraformsubnet" { resource "azurerm_subnet" "my_terraform_subnet" {
name = "mySubnet" name = "mySubnet"
resource_group_name = azurerm_resource_group.rg.name resource_group_name = azurerm_resource_group.rg.name
virtual_network_name = azurerm_virtual_network.myterraformnetwork.name virtual_network_name = azurerm_virtual_network.my_terraform_network.name
address_prefixes = ["10.0.1.0/24"] address_prefixes = ["10.0.1.0/24"]
} }
# Create public IPs # Create public IPs
resource "azurerm_public_ip" "myterraformpublicip" { resource "azurerm_public_ip" "my_terraform_public_ip" {
name = "myPublicIP" name = "myPublicIP"
location = azurerm_resource_group.rg.location location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name resource_group_name = azurerm_resource_group.rg.name
@ -32,7 +32,7 @@ resource "azurerm_public_ip" "myterraformpublicip" {
} }
# Create Network Security Group and rule # Create Network Security Group and rule
resource "azurerm_network_security_group" "myterraformnsg" { resource "azurerm_network_security_group" "my_terraform_nsg" {
name = "myNetworkSecurityGroup" name = "myNetworkSecurityGroup"
location = azurerm_resource_group.rg.location location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name resource_group_name = azurerm_resource_group.rg.name
@ -51,27 +51,27 @@ resource "azurerm_network_security_group" "myterraformnsg" {
} }
# Create network interface # Create network interface
resource "azurerm_network_interface" "myterraformnic" { resource "azurerm_network_interface" "my_terraform_nic" {
name = "myNIC" name = "myNIC"
location = azurerm_resource_group.rg.location location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name resource_group_name = azurerm_resource_group.rg.name
ip_configuration { ip_configuration {
name = "myNicConfiguration" name = "my_nic_configuration"
subnet_id = azurerm_subnet.myterraformsubnet.id subnet_id = azurerm_subnet.my_terraform_subnet.id
private_ip_address_allocation = "Dynamic" private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.myterraformpublicip.id public_ip_address_id = azurerm_public_ip.my_terraform_public_ip.id
} }
} }
# Connect the security group to the network interface # Connect the security group to the network interface
resource "azurerm_network_interface_security_group_association" "example" { resource "azurerm_network_interface_security_group_association" "example" {
network_interface_id = azurerm_network_interface.myterraformnic.id network_interface_id = azurerm_network_interface.my_terraform_nic.id
network_security_group_id = azurerm_network_security_group.myterraformnsg.id network_security_group_id = azurerm_network_security_group.my_terraform_nsg.id
} }
# Generate random text for a unique storage account name # Generate random text for a unique storage account name
resource "random_id" "randomId" { resource "random_id" "random_id" {
keepers = { keepers = {
# Generate a new ID only when a new resource group is defined # Generate a new ID only when a new resource group is defined
resource_group = azurerm_resource_group.rg.name resource_group = azurerm_resource_group.rg.name
@ -81,8 +81,8 @@ resource "random_id" "randomId" {
} }
# Create storage account for boot diagnostics # Create storage account for boot diagnostics
resource "azurerm_storage_account" "mystorageaccount" { resource "azurerm_storage_account" "my_storage_account" {
name = "diag${random_id.randomId.hex}" name = "diag${random_id.random_id.hex}"
location = azurerm_resource_group.rg.location location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name resource_group_name = azurerm_resource_group.rg.name
account_tier = "Standard" account_tier = "Standard"
@ -96,11 +96,11 @@ resource "tls_private_key" "example_ssh" {
} }
# Create virtual machine # Create virtual machine
resource "azurerm_linux_virtual_machine" "myterraformvm" { resource "azurerm_linux_virtual_machine" "my_terraform_vm" {
name = "myVM" name = "myVM"
location = azurerm_resource_group.rg.location location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name resource_group_name = azurerm_resource_group.rg.name
network_interface_ids = [azurerm_network_interface.myterraformnic.id] network_interface_ids = [azurerm_network_interface.my_terraform_nic.id]
size = "Standard_DS1_v2" size = "Standard_DS1_v2"
os_disk { os_disk {
@ -126,6 +126,6 @@ resource "azurerm_linux_virtual_machine" "myterraformvm" {
} }
boot_diagnostics { boot_diagnostics {
storage_account_uri = azurerm_storage_account.mystorageaccount.primary_blob_endpoint storage_account_uri = azurerm_storage_account.my_storage_account.primary_blob_endpoint
} }
} }

View File

@ -3,7 +3,7 @@ output "resource_group_name" {
} }
output "public_ip_address" { output "public_ip_address" {
value = azurerm_linux_virtual_machine.myterraformvm.public_ip_address value = azurerm_linux_virtual_machine.my_terraform_vm.public_ip_address
} }
output "tls_private_key" { output "tls_private_key" {