terraform: created terraform-configurations/5/configuration-5.tf
This commit is contained in:
parent
ce9448ed98
commit
dc97571219
125
terraform-configurations/5/configuration-5.tf
Normal file
125
terraform-configurations/5/configuration-5.tf
Normal file
@ -0,0 +1,125 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
skip_provider_registration = true
|
||||
}
|
||||
|
||||
locals {
|
||||
image_parts = split(":", "Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest")
|
||||
}
|
||||
|
||||
data "azurerm_resource_group" "simpl_rg" {
|
||||
name = "rg-neoImpact-northeurope"
|
||||
}
|
||||
|
||||
resource "azurerm_virtual_network" "simpl_vnet" {
|
||||
name = "simpl-vnet-5"
|
||||
address_space = ["10.0.0.0/16"]
|
||||
location = data.azurerm_resource_group.simpl_rg.location
|
||||
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||
}
|
||||
|
||||
resource "azurerm_subnet" "simpl_subnet" {
|
||||
name = "simpl-subnet-5"
|
||||
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||
virtual_network_name = azurerm_virtual_network.simpl_vnet.name
|
||||
address_prefixes = ["10.0.1.0/24"]
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "simpl_pip" {
|
||||
name = "simpl-pip-5"
|
||||
location = data.azurerm_resource_group.simpl_rg.location
|
||||
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||
allocation_method = "Static"
|
||||
sku = "Standard"
|
||||
}
|
||||
|
||||
resource "azurerm_network_interface" "simpl_nic" {
|
||||
name = "simpl-nic-5"
|
||||
location = data.azurerm_resource_group.simpl_rg.location
|
||||
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||
|
||||
ip_configuration {
|
||||
name = "internal"
|
||||
subnet_id = azurerm_subnet.simpl_subnet.id
|
||||
private_ip_address_allocation = "Dynamic"
|
||||
public_ip_address_id = azurerm_public_ip.simpl_pip.id
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_network_security_group" "simpl_nsg" {
|
||||
count = 1
|
||||
name = "simpl-nsg-5"
|
||||
location = data.azurerm_resource_group.simpl_rg.location
|
||||
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||
|
||||
security_rule {
|
||||
name = "allow-ssh"
|
||||
priority = 100
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_range = "22"
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
|
||||
security_rule {
|
||||
name = "allow-app"
|
||||
priority = 110
|
||||
direction = "Inbound"
|
||||
access = "Allow"
|
||||
protocol = "Tcp"
|
||||
source_port_range = "*"
|
||||
destination_port_ranges = ["80"]
|
||||
source_address_prefix = "*"
|
||||
destination_address_prefix = "*"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_network_interface_security_group_association" "simpl_nic_nsg" {
|
||||
count = 1
|
||||
network_interface_id = azurerm_network_interface.simpl_nic.id
|
||||
network_security_group_id = azurerm_network_security_group.simpl_nsg[0].id
|
||||
}
|
||||
|
||||
resource "azurerm_linux_virtual_machine" "simpl_vm" {
|
||||
name = "offering-enterprise-server-5-terraform"
|
||||
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||
location = data.azurerm_resource_group.simpl_rg.location
|
||||
size = "Standard_D2s_v3"
|
||||
admin_username = "simpluser"
|
||||
admin_password = "01y8U0i7P1v22E9qz1T0"
|
||||
disable_password_authentication = false
|
||||
|
||||
network_interface_ids = [azurerm_network_interface.simpl_nic.id]
|
||||
|
||||
os_disk {
|
||||
caching = "ReadWrite"
|
||||
storage_account_type = "Standard_LRS"
|
||||
disk_size_gb = 30
|
||||
}
|
||||
|
||||
source_image_reference {
|
||||
publisher = local.image_parts[0]
|
||||
offer = local.image_parts[1]
|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zdG9wcGVkIC1lIERBU0hCT0FSRF9VU0VSPSdsYXJ1ZWNhYXNvY2lhY2lvbicgLWUgREFTSEJPQVJEX1BBU1NXT1JEPScyNDNGR3RYMEJrJyBhY3JldGxuZW9jay5henVyZWNyLmlvL2Rhc2hib2FyZC1pbmRpY2Fkb3Jlcy1zb2NpYWxlczoxLjQuMSIKICAtIHVmdyBhbGxvdyAyMi90Y3AKICAtIHVmdyBhbGxvdyA4MC90Y3AKICAtIHVmdyAtLWZvcmNlIGVuYWJsZQogIC0gc3lzdGVtY3RsIHJlc3RhcnQgc3NoZAoKd3JpdGVfZmlsZXM6CiAgLSBwYXRoOiAvZXRjL3NzaC9zc2hkX2NvbmZpZy5kL3NpbXBsLWhhcmRlbmluZy5jb25mCiAgICBjb250ZW50OiB8CiAgICAgIFBlcm1pdFJvb3RMb2dpbiBubwogICAgICBQYXNzd29yZEF1dGhlbnRpY2F0aW9uIHllcwogICAgICBNYXhBdXRoVHJpZXMgNQogICAgb3duZXI6IHJvb3Q6cm9vdAogICAgcGVybWlzc2lvbnM6ICIwNjQ0Ig=="
|
||||
}
|
||||
|
||||
output "vmIps" {
|
||||
depends_on = [azurerm_linux_virtual_machine.simpl_vm]
|
||||
value = [azurerm_public_ip.simpl_pip.ip_address]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user