dependency/azapi_examples/Microsoft.Compute_virtualMachineScaleSets_extensions@2023-03-01/main.tf (208 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 = "internal" 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" "virtualMachineScaleSet" { type = "Microsoft.Compute/virtualMachineScaleSets@2023-03-01" parent_id = azapi_resource.resourceGroup.id name = var.resource_name location = var.location body = { properties = { additionalCapabilities = { } doNotRunExtensionsOnOverprovisionedVMs = false orchestrationMode = "Uniform" overprovision = true scaleInPolicy = { forceDeletion = false rules = [ "Default", ] } singlePlacementGroup = true upgradePolicy = { mode = "Manual" } virtualMachineProfile = { diagnosticsProfile = { bootDiagnostics = { enabled = false storageUri = "" } } extensionProfile = { extensionsTimeBudget = "PT1H30M" } networkProfile = { networkInterfaceConfigurations = [ { name = "example" properties = { dnsSettings = { dnsServers = [ ] } enableAcceleratedNetworking = false enableIPForwarding = false ipConfigurations = [ { name = "internal" properties = { applicationGatewayBackendAddressPools = [ ] applicationSecurityGroups = [ ] loadBalancerBackendAddressPools = [ ] loadBalancerInboundNatPools = [ ] primary = true privateIPAddressVersion = "IPv4" subnet = { id = azapi_resource.subnet.id } } }, ] primary = true } }, ] } osProfile = { adminUsername = "adminuser" computerNamePrefix = var.resource_name linuxConfiguration = { disablePasswordAuthentication = true provisionVMAgent = true ssh = { publicKeys = [ { keyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+wWK73dCr+jgQOAxNsHAnNNNMEMWOHYEccp6wJm2gotpr9katuF/ZAdou5AaW1C61slRkHRkpRRX9FA9CYBiitZgvCCz+3nWNN7l/Up54Zps/pHWGZLHNJZRYyAB6j5yVLMVHIHriY49d/GZTZVNB8GoJv9Gakwc/fuEZYYl4YDFiGMBP///TzlI4jhiJzjKnEvqPFki5p2ZRJqcbCiF4pJrxUQR/RXqVFQdbRLZgYfJ8xGB878RENq3yQ39d8dVOkq4edbkzwcUmwwwkYVPIoDGsYLaRHnG+To7FvMeyO7xDVQkMKzopTQV8AuKpyvpqu0a9pWOMaiCyDytO7GGN you@me.com" path = "/home/adminuser/.ssh/authorized_keys" }, ] } } secrets = [ ] } priority = "Regular" storageProfile = { dataDisks = [ ] imageReference = { offer = "UbuntuServer" publisher = "Canonical" sku = "16.04-LTS" version = "latest" } osDisk = { caching = "ReadWrite" createOption = "FromImage" managedDisk = { storageAccountType = "Standard_LRS" } osType = "Linux" writeAcceleratorEnabled = false } } } } sku = { capacity = 1 name = "Standard_F2" tier = "Standard" } } schema_validation_enabled = false response_export_values = ["*"] } resource "azapi_resource" "extension" { type = "Microsoft.Compute/virtualMachineScaleSets/extensions@2023-03-01" parent_id = azapi_resource.virtualMachineScaleSet.id name = var.resource_name body = { properties = { autoUpgradeMinorVersion = true enableAutomaticUpgrade = false provisionAfterExtensions = [ ] publisher = "Microsoft.Azure.Extensions" settings = { commandToExecute = "echo $HOSTNAME" } suppressFailures = false type = "CustomScript" typeHandlerVersion = "2.0" } } schema_validation_enabled = false response_export_values = ["*"] }