Skip to content

smartloop-ai/tf_azure_vm_provision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure VM Provisioning with Terraform

This project provisions an Azure Virtual Machine using Terraform. It supports multiple admin users via SSH keys, custom VM sizing, and tagging for IaC.

Prerequisites

  • Terraform installed
  • Azure CLI installed and authenticated (az login)
  • Sufficient permissions to create resources in the target Azure subscription
  • SSH public keys for all admin users

Setup

  1. Clone this repository and navigate to the project directory.

  2. Edit terraform.tfvars to set your Azure resource group, subscription, network, VM size, and admin SSH keys. Example:

resource_name   = "smartlp"
subscription_id = "<your-subscription-id>"
vpc_cidr_block  = "10.0.0.0/18"
vm_size         = "Standard_NC40ads_H100_v5"

admin_ssh_keys = [
  {
    username   = "mehfuz"
    public_key = "/home/mehfuz/.ssh/id_rsa.pub"
  },
]
  • Each entry in admin_ssh_keys will create a separate admin user on the VM with the specified SSH public key.
  • The value for public_key should be the path to the public key file (not the key string itself).
  1. Initialize Terraform:
terraform init
  1. Review the plan:
terraform plan
  1. Apply the plan:
terraform apply
  • Confirm the action when prompted.

Outputs

  • The public IP address of the VM will be displayed after a successful apply.
  • Admin users are provisioned as specified in terraform.tfvars.

Notes

  • The VM is created in the specified resource group and region.
  • Secure boot is disabled by default.
  • The VM is tagged with IaC = true.
  • To destroy the resources, run:
    terraform destroy

Troubleshooting

  • Ensure your SSH public key files exist and are readable.
  • Make sure you have the correct permissions in Azure.
  • If you see variable errors, check that all required variables are set in terraform.tfvars.
  • If you do not see the public IP in the output, check that the output block in outputs.tf matches the resource name and is not commented out.

For more details, see the comments in each .tf file.

About

Terraform plan to provision azure VM

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages