Aria Automation & Terraform - Part 2
This guide will cover the creation of the Aria Automation Cloud Accounts and Cloud Zones. Before getting started, follow Part 1 to configure the Aria Automation / VCF Automation provider for terraform.
The first terraform resource to create is the Cloud Accounts. Create a new file called "cloud_accounts.tf" and add the code below. The first account to be added is to a vSphere environment. The resource is of type 'vra_cloud_account_vsphere' and called 'homelab' in this example. A second data source is required to enumerate the available regions within the vSphere environment.
1resource "vra_cloud_account_vsphere" "homelab" {
2 name = "tf-vsphere-homelab"
3 description = "Homelab vSphere environment"
4 username = var.vsphere_username
5 password = var.vsphere_password
6 hostname = var.vsphere_hostname
7 regions = data.vra_region_enumeration_vsphere.this.regions
8
9 accept_self_signed_cert = true
10
11 tags {
12 key = "cloud"
13 value = "vsphere"
14 }
15}
16
17data "vra_region_enumeration_vsphere" "this" {
18 username = var.vsphere_username
19 password = var.vsphere_password
20 hostname = var.vsphere_hostname
21
22 accept_self_signed_cert = true
23}
Add the new variables to your variables.tf file.
1# Input variable: vsphere_hostname
2variable "vsphere_hostname" {
3 description = "Hostname of the vSphere server"
4 type = string
5}
6
7# Input variable: vsphere_username
8variable "vsphere_username" {
9 description = "Username of the user to authenticate to vSphere"
10 type = string
11 default = "administrator@vsphere.local"
12 sensitive = true
13}
14
15# Input variable: vsphere_password
16variable "vsphere_password" {
17 description = "Password of the user to authenticate to vSphere"
18 type = string
19 default = "your_password"
20 sensitive = true
21}
22
23# Input variable: regions
24variable "regions" {
25 description = "The vSphere Regions to be added as part of the Cloud Account"
26 type = list(string)
27}
Add the variable values to the variables.tfvars file.
1url = "https://vaa.homelab.local"
2insecure = false
3username = "configadmin"
4password = "S3cur3P@ssw0rd!"
5vsphere_hostname = "vcenter.homelab.local"
6vsphere_username = "administrator@vsphere.local"
7vsphere_password = "S3cur3P@ssw0rd!"
8regions = ""
With all the files now created, run the command terraform plan -var-file="variables.tfvars" and confirm everything looks correct and that your new resource will be created, and then run terraform apply.
Once the apply command has finished, in Aria Automation you will see the new Cloud Account created with the properties configured exactly as set in the "cloud_accounts.tf" file.
To configure additional Cloud Accounts for different cloud providers such as AWS, Azure or GCP, follow the HashiCorp documentation available here.