Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

How to deploy a Windows VM with Terraform Azure CAF?

I want to deploy a Windows VM with Azure Cloud Adoption Framework (CAF) using Terraform. In the example of configuration.tfvars, all the configuration is done.But I cannot find the correct terraform code to deploy this tfvars configuration.

The windows vm module is here.

So far, i have written the code below:

module "caf_virtual_machine" {
  source  = "aztfmod/caf/azurerm//modules/compute/virtual_machine"
  version = "5.0.0"
  # belows are the 7 required variables 

  base_tags = var.tags
  client_config = 
  global_settings = var.global_settings
  location = var.location
  resource_group_name = var.resource_group_name
  settings = 
  vnets =  var.vnets  
}

So the vnets, global_settings, resource_group_name variables already exists in the configuration.tfvars. I have added tags and location variables to the configuration.tfvars.

But what should i enter to settings and client_config variables?

question from:https://stackoverflow.com/questions/65928717/how-to-deploy-a-windows-vm-with-terraform-azure-caf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The virtual machine is a private module. You should use it by calling the base CAF module.

The Readme of the terraform registry explains how to leverage the core CAF module - https://registry.terraform.io/modules/aztfmod/caf/azurerm/latest/submodules/virtual_machine

Source code of an example: https://github.com/aztfmod/terraform-azurerm-caf/tree/master/examples/compute/virtual_machine/211-vm-bastion-winrm-agents/registry

You have a library of configuration files examples showing how to deploy virtual machines

https://github.com/aztfmod/terraform-azurerm-caf/tree/master/examples/compute/virtual_machine

   module "caf" {
    source  = "aztfmod/caf/azurerm"
    version = "5.0.0"
    
    global_settings    = var.global_settings
    tags               = var.tags
    resource_groups    = var.resource_groups
    storage_accounts   = var.storage_accounts
    keyvaults          = var.keyvaults
    managed_identities = var.managed_identities
    role_mapping       = var.role_mapping
    
    diagnostics = {
      # Get the diagnostics settings of services to create
      diagnostic_log_analytics    = var.diagnostic_log_analytics
      diagnostic_storage_accounts = var.diagnostic_storage_accounts
    }
    
    compute = {
      virtual_machines = var.virtual_machines
    }
    
    networking = {
      vnets                             = var.vnets
      network_security_group_definition = var.network_security_group_definition
      public_ip_addresses               = var.public_ip_addresses
    }
    
    security = {
      dynamic_keyvault_secrets = var.dynamic_keyvault_secrets
    }
  }

Note - it is recommended to leverage the VScode devcontainer provided in the source repository to execute the terraform deployment. The devcontainer includes the tooling required to deploy Azure solutions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...