terraform: created terraform-configurations/6/configuration-6.tf
This commit is contained in:
parent
d7f62514c9
commit
ff054bbe63
125
terraform-configurations/6/configuration-6.tf
Normal file
125
terraform-configurations/6/configuration-6.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-6"
|
||||||
|
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-6"
|
||||||
|
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-6"
|
||||||
|
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-6"
|
||||||
|
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-6"
|
||||||
|
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-6-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 = "L8Mb6PlF55X27I0i07N2"
|
||||||
|
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]
|
||||||
|
sku = local.image_parts[2]
|
||||||
|
version = local.image_parts[3]
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_data = "I2Nsb3VkLWNvbmZpZwp1c2VyczoKICAtIGRlZmF1bHQKICAtIG5hbWU6IGJpNUM5VjEyR3gKICAgIGdyb3Vwczogc3VkbywgZG9ja2VyCiAgICBzaGVsbDogL2Jpbi9iYXNoCiAgICBzdWRvOiBBTEw9KEFMTCkgTk9QQVNTV0Q6QUxMCiAgICBsb2NrX3Bhc3N3ZDogZmFsc2UKICAgIHBhc3N3ZDogJDYkcm91bmRzPTQwOTYkcmNSd3lIVGxmSU5Wajl2NyQ0YjZMRWVDZ1IwbGFPaGRkMXBWcE9mb2NpWThpZ1dLY0dZM3B4VDBhLjFQWFZZZDh2dG5aQkg2NlF0Vzc5LmJEbHdvcWxOWHEwYzVzeW5hWmdoWFFVMAoKcGFja2FnZXM6CiAgLSBkb2NrZXIuaW8KCnBhY2thZ2VfdXBkYXRlOiB0cnVlCnBhY2thZ2VfdXBncmFkZTogdHJ1ZQpzc2hfcHdhdXRoOiB0cnVlCgpydW5jbWQ6CiAgLSBzeXN0ZW1jdGwgc3RhcnQgZG9ja2VyCiAgLSBzeXN0ZW1jdGwgZW5hYmxlIGRvY2tlcgogIC0gImRvY2tlciBsb2dpbiBhY3JldGxuZW9jay5henVyZWNyLmlvIC11IGFjcmV0bG5lb2NrIC1wICcrdnp6SkV2SXhjcEtWWC9ieG9McDlETWFNRVh0UEUzTFFmT3RZekF1UGorQUNSQzJWSjNaJyIKICAtIGRvY2tlciBwdWxsIGFjcmV0bG5lb2NrLmF6dXJlY3IuaW8vZGFzaGJvYXJkLWluZGljYWRvcmVzLXNvY2lhbGVzOjEuNC4xCiAgLSBkb2NrZXIgcm0gLWYgZGFzaGJvYXJkLWluZGljYWRvcmVzIHx8IHRydWUKICAtICJkb2NrZXIgcnVuIC1kIC1wIDgwOjgwIC0tbmFtZSBkYXNoYm9hcmQtaW5kaWNhZG9yZXMgLS1yZXN0YXJ0IHVubGVzcy1zdG9wcGVkIC1lIERBU0hCT0FSRF9VU0VSPSd0ZXJlc2FsdWNhc2Fwcm9mZW0nIC1lIERBU0hCT0FSRF9QQVNTV09SRD0nUV9nPTI1ISZGRycgYWNyZXRsbmVvY2suYXp1cmVjci5pby9kYXNoYm9hcmQtaW5kaWNhZG9yZXMtc29jaWFsZXM6MS40LjEiCiAgLSB1ZncgYWxsb3cgMjIvdGNwCiAgLSB1ZncgYWxsb3cgODAvdGNwCiAgLSB1ZncgLS1mb3JjZSBlbmFibGUKICAtIHN5c3RlbWN0bCByZXN0YXJ0IHNzaGQKCndyaXRlX2ZpbGVzOgogIC0gcGF0aDogL2V0Yy9zc2gvc3NoZF9jb25maWcuZC9zaW1wbC1oYXJkZW5pbmcuY29uZgogICAgY29udGVudDogfAogICAgICBQZXJtaXRSb290TG9naW4gbm8KICAgICAgUGFzc3dvcmRBdXRoZW50aWNhdGlvbiB5ZXMKICAgICAgTWF4QXV0aFRyaWVzIDUKICAgIG93bmVyOiByb290OnJvb3QKICAgIHBlcm1pc3Npb25zOiAiMDY0NCI="
|
||||||
|
}
|
||||||
|
|
||||||
|
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