This project provisions an Azure Virtual Machine using Terraform. It supports multiple admin users via SSH keys, custom VM sizing, and tagging for IaC.
- 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
-
Clone this repository and navigate to the project directory.
-
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).
- Initialize Terraform:
terraform init
- Review the plan:
terraform plan
- Apply the plan:
terraform apply
- Confirm the action when prompted.
- The public IP address of the VM will be displayed after a successful apply.
- Admin users are provisioned as specified in
terraform.tfvars
.
- 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
- 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.