Add Prueba_13_20260519_151519.TF
This commit is contained in:
parent
9ce8561829
commit
678eec1a3b
124
Prueba_13_20260519_151519.TF
Normal file
124
Prueba_13_20260519_151519.TF
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
azurerm = {
|
||||||
|
source = "hashicorp/azurerm"
|
||||||
|
version = "~> 4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "azurerm" {
|
||||||
|
features {}
|
||||||
|
skip_provider_registration = true
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
image_parts = split(":", "canonical")
|
||||||
|
}
|
||||||
|
|
||||||
|
data "azurerm_resource_group" "simpl_rg" {
|
||||||
|
name = "Grupo de recursos"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_virtual_network" "simpl_vnet" {
|
||||||
|
name = "simpl-vnet-{UUID}"
|
||||||
|
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-{UUID}"
|
||||||
|
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-{UUID}"
|
||||||
|
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-{UUID}"
|
||||||
|
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-{UUID}"
|
||||||
|
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 = ["4555"]
|
||||||
|
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-{UUID}-terraform"
|
||||||
|
resource_group_name = data.azurerm_resource_group.simpl_rg.name
|
||||||
|
location = data.azurerm_resource_group.simpl_rg.location
|
||||||
|
size = "Standard_B2s (2 vCPU, 4 GB RAM)"
|
||||||
|
admin_username = "simpluser"
|
||||||
|
admin_password = "var.simpl_admin_password"
|
||||||
|
disable_password_authentication = false
|
||||||
|
|
||||||
|
network_interface_ids = [azurerm_network_interface.simpl_nic.id]
|
||||||
|
|
||||||
|
os_disk {
|
||||||
|
caching = "ReadWrite"
|
||||||
|
storage_account_type = "Standard_LRS"
|
||||||
|
}
|
||||||
|
|
||||||
|
source_image_reference {
|
||||||
|
publisher = local.image_parts[0]
|
||||||
|
offer = local.image_parts[1]
|
||||||
|
sku = local.image_parts[2]
|
||||||
|
version = local.image_parts[3]
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_data = "var.simpl_cloud_init"
|
||||||
|
}
|
||||||
|
|
||||||
|
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