terraform: created terraform-configurations/15/configuration-15.tf
This commit is contained in:
parent
a102803bbe
commit
1904967ff3
106
terraform-configurations/15/configuration-15.tf
Normal file
106
terraform-configurations/15/configuration-15.tf
Normal file
@ -0,0 +1,106 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
provider "azurerm" {
|
||||
skip_provider_registration = true
|
||||
features {}
|
||||
}
|
||||
locals {
|
||||
image_parts = split(":", "Canonical:0001-com-ubuntu-server-jammy:22_04-lts-gen2:latest")
|
||||
}
|
||||
data "azurerm_resource_group" "simpl_rg" {
|
||||
name = "espacios-de-datos-infraestructura"
|
||||
}
|
||||
resource "azurerm_virtual_network" "simpl_vnet" {
|
||||
name = "simpl-vnet-15"
|
||||
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-15"
|
||||
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-15"
|
||||
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-15"
|
||||
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-15"
|
||||
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 = ["8088"]
|
||||
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-15-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 = "BH36P9DJ509Vfcq107k4"
|
||||
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 = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIGRlZmF1bHQg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cGVyc2V0IHN1cGVyc2V0IGRiIHVwZ3JhZGUKICAtIGRvY2tlciBleGVjIHN1cGVyc2V0IHN1cGVyc2V0IGxvYWRfZXhhbXBsZXMKICAtIGRvY2tlciBleGVjIHN1cGVyc2V0IHN1cGVyc2V0IGluaXQKICAtIGRvY2tlciByZXN0YXJ0IHN1cGVyc2V0CiAgLSB1ZncgYWxsb3cgMjIvdGNwCiAgLSB1ZncgYWxsb3cgODA4OC90Y3AKICAtIHVmdyAtLWZvcmNlIGVuYWJsZQogIC0gc3lzdGVtY3RsIHJlc3RhcnQgc3NoZAoKd3JpdGVfZmlsZXM6CiAgLSBwYXRoOiAvZXRjL3NzaC9zc2hkX2NvbmZpZy5kL3NpbXBsLWhhcmRlbmluZy5jb25mCiAgICBjb250ZW50OiB8CiAgICAgIFBlcm1pdFJvb3RMb2dpbiBubwogICAgICBQYXNzd29yZEF1dGhlbnRpY2F0aW9uIHllcwogICAgICBNYXhBdXRoVHJpZXMgNQogICAgb3duZXI6IHJvb3Q6cm9vdAogICAgcGVybWlzc2lvbnM6ICcwNjQ0Jw=="
|
||||
}
|
||||
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