OpenTofu/Terraform code to launch a Ampere virtual machines on Microsoft Azure.
The goal of this code is to supply the minimal ammount of information to quickly have working Ampere virtual machines on "Azure". Virtual machines are configured with a simple cloud-config using the Azure metadata provider APIs.
Addtional tasks performed by this code:
- Dynamically creating sshkeys to use when logging into the instance.
- Creating necessary core networking configurations for the tenancy
- Rendering metadata to pass into the Ampere virtual machine
- Launch Ampere virtual machine with metadata and ssh keys.
- Output IP information to connect to the instance.
To get started clone this repository from GitHub locally.
The easiest way to configure is to use a terraform.tfvars in the project directory.
The following is an example of what terraform.tfvars should look like:
subscription_id = "12345678-abcd-1234-abcd-1234567890ab"
tenant_id = "87654321-dcba-4321-dcba-ba0987654321"
This can also be used as a OpenTofu or Terraform module. The examples directory contains example code for module usage showing different operating systems booting with a custom cloud-init templates. Doing a clone of this repository and changing directory to one of the examples, placing a terraform.tfvars into that directory, and running a typical terrafornm workflow will produce a working virtual machine in the os that was specified in the main.tf that is located within the chosen example directory.
tofu init && tofu plan && tofu apply -auto-approve
terraform init && terraform plan && terraform apply -auto-approve
variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "almalinux8"
instance_prefix = "azure-ampere-vm-almalinux8"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "debian11"
instance_prefix = "azure-ampere-vm-debian-11"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "mariner"
instance_prefix = "azure-ampere-vm-mariner"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "opensuse"
instance_prefix = "azure-ampere-vm-opensuse-15"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "ubuntu1804"
instance_prefix = "azure-ampere-vm-ubuntu-1804"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "ubuntu2004"
instance_prefix = "azure-ampere-vm-ubuntu-2004"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}variable "subscription_id" {}
variable "tenant_id" {}
locals {
cloud_init_template_path = "${path.cwd}/cloud-init.yaml.tpl"
}
module "azure-ampere-vm" {
source = "github.com/amperecomputing/terraform-azure-ampere-vm"
subscription_id = var.subscription_id
tenant_id = var.tenant_id
# Optional
# resource_group = var.resource_group
# rg_prefix = var.rg_prefix
# virtual_network_name = var.virtual_network_name
# address_space = var.address_space
# subnet_prefix = var.subnet_prefix
# vm_size = var.vm_size
location = "westus2"
azure_vm_count = 1
azure_os_image = "ubuntu2204"
instance_prefix = "azure-ampere-vm-ubuntu-2204"
cloud_init_template_file = local.cloud_init_template_path
}
output "azure_ampere_vm_private_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_private_ipaddresses
}
output "azure_ampere_vm_public_ips" {
value = module.azure-ampere-vm.azure_ampere_vm_public_ipaddresses
}| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| address_space | The address space that is used by the virtual network. You can supply more than one address space. Changing this forces a new resource to be created. | string |
"10.2.0.0/16" |
no |
| azure_os_image | Default OS Image From the Local Vars | string |
"ubuntu2004" |
no |
| azure_vm_count | Azure Ampere Virtual machine Config | number |
1 |
no |
| cloud_init_template_file | Optional path for a cloud-init file | string |
null |
no |
| instance_prefix | Name prefix for vm instances | string |
"azure-ampere-vm" |
no |
| location | The location/region where the virtual network is created. Changing this forces a new resource to be created. | string |
"westus2" |
no |
| resource_group | The name of the resource group in which to create the virtual network. | string |
"Terraform-Ampere-on-Azure" |
no |
| rg_prefix | The shortened abbreviation to represent your resource group that will go on the front of some resources. | string |
"rg" |
no |
| subnet_prefix | The address prefix to use for the subnet. | string |
"10.2.1.0/24" |
no |
| subscription_id | Azure Credentials | string |
"Azure Subscription ID" |
no |
| tags | n/a | map |
{ |
no |
| tenant_id | n/a | string |
"Azure Tenant ID" |
no |
| virtual_network_name | The name for the virtual network. | string |
"vnet" |
no |
| vm_size | Specifies the size of the Azure Ampere virtual machine. | string |
"Standard_D16ps_v5" |
no |
No modules.
| Name | Description |
|---|---|
| azure_ampere_vm_private_ipaddresses | Output the Azure VM(s)) private/internal ip address |
| azure_ampere_vm_public_ipaddresses | Output the Azure VM(s)) public/external ip address |
| azure_ampere_vm_ssh_private_key | Output the Azure SSH private key |
| azure_ampere_vm_ssh_public_key | Output the Azure SSH public key |
| azure_current_subscription_display_name | Output the Display Name for the current Azure Subscription |
| azure_ssh_private_key | output the Azure SSH private key |
| azure_ssh_pubic_key | output the Azure SSH public key |
| random_uuid | Output: A randomly generated uuid |
| Name | Version |
|---|---|
| azurerm | n/a |
| local | n/a |
| random | n/a |
| tls | n/a |
| Name | Type |
|---|---|
| azurerm_network_interface.nic | resource |
| azurerm_network_security_group.nsg | resource |
| azurerm_public_ip.pip | resource |
| azurerm_resource_group.rg | resource |
| azurerm_subnet.subnet | resource |
| azurerm_virtual_machine.vm | resource |
| azurerm_virtual_network.vnet | resource |
| local_file.azure-ssh-privkey | resource |
| local_file.azure-ssh-pubkey | resource |
| random_uuid.random_id | resource |
| tls_private_key.azure | resource |
| azurerm_public_ip.pip | data source |
| azurerm_subscription.current | data source |
No requirements.
- Now in preview Azure virtual machines with ampere altra based processors
- Microsoft Rolls Out Ampere Altra Arm CPUs in Azure
- Microsoft arms Azure VMs with Ampere Altra chips
- Microsoft brings Arm support to Azure virtual machines
- Ampere® Altra® Now Available on Microsoft® Azure Cloud Platform
- Microsoft Azure Adds Ampere Altra Arm CPUs
- Microsoft Adds Ampere ARM CPU Support to Azure Virtual Machines
- Terraform Azure Provider
- Install the Azure CLI on Linux
- Install Azure CLI on macOS
- Install Azure CLI on Windows
- Azure CLI authentication in Terraform
- cloud-init support for virtual machines in Azure