Skip to content

Instantly share code, notes, and snippets.

variable "resource_group_name_prefix" {
default = "rg"
description = "Prefix of the resource group name"
}
variable "resource_group_name" {
default = "prefix_SomeName"
description = "Resource group name"
}
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.92.0"
}
}
backend "azurerm" {
resource_group_name = "${var.resource_group_name}"
output "public_ip_address" {
value = azurerm_linux_virtual_machine.yourvmname.public_ip_address
}
output "azurerm_linux_virtual_machine_name" {
value = azurerm_linux_virtual_machine.yourvmname.name
}
output "resource_group_name" {
value = azurerm_linux_virtual_machine.yourvmname.resource_group_name
locals { 
secrules= {
 ssh = {
 name = "SSH"
 priority = 300
 direction = "Inbound"
 access = "Allow"
 protocol = "Tcp"
 source_port_range = "*"
 destination_port_range = "22"
@imartinflores
imartinflores / main-nic.tf
Created June 30, 2023 14:32
Virtual Networs
resource "azurerm_network_interface" "networkinterfacename" {
 name = "${var.resource_group_name}-department-nic"
 location = var.vm_location
 resource_group_name = var.resource_group_name
 ip_configuration {
 name = "${var.resource_group_name}-department-IpConfig"
 subnet_id = azurerm_subnet.subnetname.id
 private_ip_address_allocation = "Dynamic"
 }
}
- task: Bash@3
displayName: create tunnel
inputs:
targetType: 'inline'
script: |
'docker run -w /datadrive -d \
-t saucelabs/sauce-connect:4.7.0 \
-u $(user) \
-k $(key) \
-x https://eu-central-1.saucelabs.com/rest/v1 \
resource "azurerm_virtual_network" "networkname" {
name = "${var.resource_group_name}-deparment-vnet"
address_space = ["addressspace/port"]
location = var.vm_location
resource_group_name = var.resource_group_name
}
resource "azurerm_subnet" "subnetname" {
name = "${var.resource_group_name}-deparment-subnet"
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.qanetwork.name
address_prefixes = ["addressprefix/port"]
}
resource "azurerm_network_interface" "networkinterfacename" {
name = "${var.resource_group_name}-department-nic"
location = var.vm_location
resource_group_name = var.resource_group_name
ip_configuration {
name = "${var.resource_group_name}-department-IpConfig"
subnet_id = azurerm_subnet.subnetname.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_linux_virtual_machine" "yourvmname" {
name = var.azurerm_linux_virtual_machine_name
location = var.vm_location
resource_group_name = var.resource_group_name
network_interface_ids = [azurerm_network_interface.qanic.id]
size = "Standard_D2s_v3"
os_disk {
name = "diskname"
caching = "ReadWrite"
storage_account_type = "Premium_LRS"