This Terraform configuration creates multiple virtual machines within a private VPC using the Abrha cloud provider.
This configuration deploys:
- VPC: A private virtual network with custom IP range
- SSH Key: Managed SSH key for VM access
- Virtual Machines: Multiple VMs (default: 1) running Ubuntu 22.04
- Terraform >= 1.0
- Abrha account with API credentials
- SSH public key for VM authentication
.
├── provider.tf # Provider configuration
├── main.tf # Main resources (VPC, VMs, SSH keys)
├── variables.tf # Variable definitions
├── outputs.tf # Output definitions
├── terraform.tfvars # Variable values (not committed)
└── terraform.tfvars.example # Example configuration
git clone <repository-url>
cd Abrha_eventCopy the example configuration and edit with your values:
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars:
abrha_api_key = "your-api-key-here"
ssh_public_key = "ssh-rsa AAAAB3... your-email@example.com"
region = "tehran3"
vm_count = 6terraform initReview the planned changes:
terraform planApply the configuration:
terraform applyView created resources:
terraform output| Variable | Description | Default | Required |
|---|---|---|---|
abrha_api_key |
Abrha API authentication key | - | Yes |
abrha_endpoint |
Abrha API endpoint URL | https://my.abrha.net/cserver/api |
No |
ssh_public_key |
SSH public key for VM access | - | Yes |
region |
Abrha region slug | tehran3 |
No |
vm_count |
Number of VMs to create | 1 |
No |
vm_size |
VM size/plan | irVPS2 |
No |
image_slug |
OS image slug | Ubuntu22-x64 |
No |
ssh_key_name |
Name for SSH key resource | main-ssh-key |
No |
vpc_name |
Name of the VPC | mainVpc |
No |
vpc_ip_range |
VPC IP address range | 192.168.20.0 |
No |
vpc_description |
VPC description | Private network for Abrha Event |
No |
After successful deployment, the following outputs are available:
vpc_id- ID of the created VPCvm_ids- List of all VM IDsvm_names- List of all VM namesvm_ips- List of VM IP addresses
Edit terraform.tfvars:
vm_count = 6Available regions: tehran3, etc.
region = "tehran3"vm_size = "irVPS4" # Check Abrha docs for available sizesterraform showAfter modifying variables or configuration:
terraform plan
terraform applyTo remove all created resources:
terraform destroy- Never commit
terraform.tfvars- Contains sensitive credentials - Use SSH keys - Password authentication is disabled
- Restrict API keys - Use minimal required permissions
- Review plans - Always run
terraform planbefore applying
Verify your API key:
export ABRHA_API_KEY="your-key"Connect to VMs using:
ssh -i ~/.ssh/your-key ubuntu@<vm-ip>If state is locked:
terraform force-unlock <lock-id>