dependency/azapi_examples/Microsoft.DevTestLab_schedules@2018-09-15/main.tf (203 lines of code) (raw):

terraform { required_providers { azapi = { source = "Azure/azapi" } } } provider "azapi" { skip_provider_registration = false } variable "resource_name" { type = string default = "acctest0001" } variable "location" { type = string default = "westeurope" } resource "azapi_resource" "resourceGroup" { type = "Microsoft.Resources/resourceGroups@2020-06-01" name = var.resource_name location = var.location } resource "azapi_resource" "virtualNetwork" { type = "Microsoft.Network/virtualNetworks@2022-07-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { addressSpace = { addressPrefixes = [ "10.0.0.0/16", ] } dhcpOptions = { dnsServers = [ ] } subnets = [ ] } } schema_validation_enabled = false response_export_values = ["*"] lifecycle { ignore_changes = [body.properties.subnets] } } resource "azapi_resource" "subnet" { type = "Microsoft.Network/virtualNetworks/subnets@2022-07-01" parent_id = azapi_resource.virtualNetwork.id name = var.resource_name body = { properties = { addressPrefix = "10.0.2.0/24" delegations = [ ] privateEndpointNetworkPolicies = "Enabled" privateLinkServiceNetworkPolicies = "Enabled" serviceEndpointPolicies = [ ] serviceEndpoints = [ ] } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "networkInterface" { type = "Microsoft.Network/networkInterfaces@2022-07-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { enableAcceleratedNetworking = false enableIPForwarding = false ipConfigurations = [ { name = "testconfiguration1" properties = { primary = true privateIPAddressVersion = "IPv4" privateIPAllocationMethod = "Dynamic" subnet = { id = azapi_resource.subnet.id } } }, ] } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "virtualMachine" { type = "Microsoft.Compute/virtualMachines@2023-03-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { additionalCapabilities = { } applicationProfile = { galleryApplications = [ ] } diagnosticsProfile = { bootDiagnostics = { enabled = false storageUri = "" } } extensionsTimeBudget = "PT1H30M" hardwareProfile = { vmSize = "Standard_B2s" } networkProfile = { networkInterfaces = [ { id = azapi_resource.networkInterface.id properties = { primary = true } }, ] } osProfile = { adminPassword = "Password1234!" adminUsername = "testadmin" allowExtensionOperations = true computerName = var.resource_name linuxConfiguration = { disablePasswordAuthentication = false patchSettings = { assessmentMode = "ImageDefault" patchMode = "ImageDefault" } provisionVMAgent = true ssh = { publicKeys = [ ] } } secrets = [ ] } priority = "Regular" storageProfile = { dataDisks = [ ] imageReference = { offer = "UbuntuServer" publisher = "Canonical" sku = "18.04-LTS" version = "latest" } osDisk = { caching = "ReadWrite" createOption = "FromImage" managedDisk = { storageAccountType = "Standard_LRS" } name = "myosdisk-230630033106863551" osType = "Linux" writeAcceleratorEnabled = false } } } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "schedule" { type = "Microsoft.DevTestLab/schedules@2018-09-15" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { dailyRecurrence = { time = "0100" } notificationSettings = { emailRecipient = "" status = "Disabled" timeInMinutes = 30 webhookUrl = "" } status = "Enabled" targetResourceId = azapi_resource.virtualMachine.id taskType = "ComputeVmShutdownTask" timeZoneId = "Pacific Standard Time" } tags = { environment = "Production" } } schema_validation_enabled = false response_export_values = ["*"] }