terraform: created terraform-configurations/3/configuration-3.tf
This commit is contained in:
parent
76a8d53575
commit
2f7bfbd773
155
terraform-configurations/3/configuration-3.tf
Normal file
155
terraform-configurations/3/configuration-3.tf
Normal file
@ -0,0 +1,155 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~> 4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
||||
|
||||
variable "simpl_resource_group" {
|
||||
type = string
|
||||
description = "Name of the pre-existing Azure Resource Group"
|
||||
}
|
||||
|
||||
variable "simpl_vm_size" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "simpl_image_urn" {
|
||||
type = string
|
||||
description = "Format: Publisher:Offer:SKU:Version (e.g. Canonical:UbuntuServer:22_04-lts:latest)"
|
||||
}
|
||||
|
||||
variable "simpl_admin_password" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "simpl_cloud_init" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "simpl_app_ports" {
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "simpl_nsg_count" {
|
||||
type = number
|
||||
}
|
||||
|
||||
locals {
|
||||
image_parts = split(":", "Canonical:UbuntuServer:22_04-lts:latest")
|
||||
}
|
||||
|
||||
data "azurerm_resource_group" "simpl_rg" {
|
||||
name = "espacios-de-datos-infraestructura"
|
||||
}
|
||||
|
||||
resource "azurerm_virtual_network" "simpl_vnet" {
|
||||
name = "simpl-vnet-3"
|
||||
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-3"
|
||||
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-3"
|
||||
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-3"
|
||||
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-3"
|
||||
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-3-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 = "66F6LfA2E98v4Lwis5vx"
|
||||
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 = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIG5hbWU6IDk1VlZVMkJrT2cKICAgIGdyb3Vwczogc3VkbywgZG9ja2VyCiAgICBzaGVsbDogL2Jpbi9iYXNoCiAgICBzdWRvOiBBTEw9KEFMTCkgTk9QQVNTV0Q6QUxMCiAgICBsb2NrX3Bhc3N3ZDogZmFsc2UKICAgIHBhc3N3ZDogJDYkcm91bmRzPTQwOTYkcmNSd3lIVGxmSU5Wajl2NyRzWmRmMGNuS1VIN25GNVBqMDZMNlRXVERZR2lPSS9RVmdULmIxaFJqeEZKUnRYZENUMEZQVHg1VjM3N0ZzT1BzNzRSM0FFWWlmenU3VWpmaWlUb3lhLgoKcGFja2FnZXM6CiAgLSBkb2NrZXIuaW8KCnBhY2thZ2VfdXBkYXRlOiB0cnVlCnBhY2thZ2VfdXBncmFkZTogdHJ1ZQpzc2hfcHdhdXRoOiB0cnVlCgpydW5jbWQ6CiAgLSBzeXN0ZW1jdGwgc3RhcnQgZG9ja2VyCiAgLSBzeXN0ZW1jdGwgZW5hYmxlIGRvY2tlcgogIC0gZG9ja2VyIHB1bGwgYXBhY2hlL3N1cGVyc2V0OmxhdGVzdAogIC0gImRvY2tl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azurerm_public_ip.simpl_pip.ip_address]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user