Modeling vRA in Terraform

To model a VMware vRealize Automation Enterprise (vRA) environment, log in with a vRealize Automation cloud project and specify the vRealize Automation-specific information in a blueprint.

Design a Terraform blueprint to do full stack provisioning using vRealize Automation (vRA) for infrastructure and UrbanCode Deploy for software automation.
  1. Create the blueprint.
  2. Select the cloud provider and region on the designer page.
    1. Verify a new Catalogs drawer appears in the palette.
    2. Verify drawer contains discovered catalogs from the vRA server.
  3. Drag a desired catalog item to the blueprint.
    1. Verify prompt appears with two options: Include catalog resources and Include server resources. By default both are selected. This feature allows for splitting catalog and servers across multiple blueprints for Terraform module development.
      1. Include catalog resource: This option denotes to create a vra7_deployment terraform resource. Values for the resource, such as input request properties, are derived from the catalog in VRA.
      2. Include server resources: This option denotes to create Terraform null resources to represent virtual machines discovered in the underlying vRA blueprint from the catalog item. The null resources will include a reference to an IP address used to make connections to running scripts. See the myvm2.ip_address and the connection on the null resource myvm2 here.
    2. Select the desired options and click OK.
  4. Verify the catalog and null resources appear in the diagram, depending on the selections made.
  5. Optional: Add a UrbanCode Deploy (UCD) component from the palette to the null resource. The UCD Terraform resources will be added to the blueprint. See IBM UrbanCode Deploy Terraform providerand a UCD provisioner will be added to the null resource which utilizes the IP address from the vRA catalog. There is also support for other provisioners such as remote_exec and local_exec using the same connection.
The following is the resources created when dragging and dropping a catalog item:
Resource vra7_deployment
resource "vra7_deployment" "aws_two_node" {
    count = "1"
    wait_timeout = "${var.aws_two_node_timeout}"
    catalog_item_name = "aws-two-node"
    resource_configuration {
        myvm2.myprop2 = "myval2"
        HelloWorld_1.myhelloprop = ""
        IBM_UrbanCode_Deploy_Agent_for_Linux_1._ucd_server_url_ = ""
        IBM_UrbanCode_Deploy_Agent_for_Linux_1._agent_name_ = ""
        IBM_UrbanCode_Deploy_Agent_for_Linux_1._ucd_password_ = ""
        myvm2.ip_address = "" # Leave blank auto populated by terraform
        myvm1.ip_address = "" # Leave blank auto populated by terraform
     }
}

https://github.com/vmware/terraform-provider-vra7 definitions are found here.


Null resource(s):
resource "null_resource" "myvm2" {
     provisioner "ucd" {
          agent_name = "${var.myvm2_agent_name}.${random_id.stack.hex}"
          ucd_server_url = "${var.ucd_server_url}"
          ucd_user = "${var.ucd_user}"
          ucd_password = "${var.ucd_password}"
     }
     provisioner "local-exec" {
          when = "destroy"
          command = <<EOT
          curl -k -u ${var.ucd_user}:${var.ucd_password} ${var.ucd_server_url}/cli/agentCLI?
          agent=${var.myvm2_agent_name}.${random_id.stack.hex} -X DELETE
          EOT
     }
     connection {
         user = "${var.myvm2_user}"
         password = "${var.myvm2_password}"
         host = "${vra7_deployment.aws_two_node.resource_configuration.myvm2.ip_address}"
     }
}