To create a new resource such as a VM, you can use the resources API to make a POST request with a project ID. The deployment creates a new resource without using a cloud template.

This procedure shows how to provision a VM with a project and a cloud zone assigned to the project. The flavor and image for the VM must exist in your cloud account.

Prerequisites

  • Verify that all general prerequisites and prerequisites for the Cloud Assembly Infrastructure as a Service (IaaS) service have been satisfied. See Prerequisites for API Use Case Examples.
  • Assign an API version variable for the Deployment API.
    api_version_deployment='2020-08-25'
    Note: The Cloud Assembly Infrastructure as a Service (IaaS) service and the Service Broker Deployment service have different API version values. You set the API version value for the Cloud Assembly Infrastructure as a Service (IaaS) service when you satisfied the general prerequisites.
  • Verify that you have the ID of the cloud account where you want to deploy the VM. See Adding Cloud Accounts.
  • Verify that you know the cloud zone in your cloud account where you want the new VM to be deployed. See Create a Cloud Zone.
  • Verify that you have the ID for a project that includes the cloud zone in your cloud account. See Add a Cloud Zone to Your Project.
  • Verify that the flavor and image for the new VM exist in your cloud account.
  • Verify that you know the resource type for the AWS machine, GCP machine, vSphere machine, or Azure machine that you plan to create. For a list of all resource types and request schema, see https://developer.vmware.com/apis/1090/vrealize-automation-cloud-resource-type-schema.

Procedure

  1. Assign the cloud account ID variable.
    cloud_account_id='<your_cloud_account_id>'
  2. Assign the project ID variable.
    project_id='<your_project_id>'
  3. List all cloud zones.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/zones?apiVersion=$api_version"  | jq "."
  4. Examine the response for the zone where you want to place your VM.
    You use the externalRegionId to filter for fabric flavor and fabric image. You use the cloud zone ID for VM placement.
  5. Assign the external region ID variable.
    external_region_id='<your_external_region_id>'
  6. Assign the cloud zone placement variable.
    placement_name='/iaas/api/zone/<your_cloud_zone_id>'
  7. To list the fabric images in your cloud account and zone, specify the cloud account ID and external region ID in the request.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" \
        "$url/iaas/api/fabric-images/?apiVersion=$api_version&"\
        '$filter'="(((externalRegionId eq '') or (externalRegionId eq '$external_region_id')) \
        and ((cloudAccountId ne '*') or cloudAccountId eq '$cloud_account_id')))" | jq "."
  8. Examine the response to select a fabric image.
  9. Assign the fabric image variable.
    image_name='<your_image_name>'
  10. To list the fabric flavors in your cloud account and zone, specify the cloud account ID and external region ID in the request.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" \ 
        "$url/iaas/api/fabric-flavors/?apiVersion=$api_version&"\
        '$filter'="(((externalRegionId eq '') or (externalRegionId eq '$external_region_id')) \
        and ((cloudAccountId ne '*') or cloudAccountId eq '$cloud_account_id')))" | jq "."
  11. Examine the response to select a fabric flavor.
  12. Assign the fabric flavor variable.
    flavor_name='<your_flavor_name>'
  13. Assign the resource type variable.
    resource_type='<your_resource_type>'
  14. Create and deploy the VM.
    curl -X POST \
      $url/deployment/api/resources?apiVersion=$api_version_deployment \
      -H "Authorization: Bearer $access_token" \
      -H "Content-Type: application/json" \
      -d '{
        "name":"<your_resource_name>",
        "projectId": "'$project_id'",
        "type":"'$resource_type'",
        "properties":{
            "imageRef": "'$image_name'",
            "flavor": "'$flavor_name'",
            "placement": "'$placement_name'"  
      },
    }' | jq "."
  15. Examine the response for the deployment ID.
  16. Assign the deployment ID.
  17. Get the status of the deployment.
    curl -X GET \
      $url/deployment/api/deployments/$deployment_id?apiVersion=$api_version_deployment \
      -H "Authorization: Bearer $access_token" | jq "."
    When the status shows CREATE_SUCCESSFUL the VM is deployed.

Example: Create and deploy a VM

With a cloud account ID and cloud zone in the cloud account, create and deploy an AWS machine named cloud_machine_1 using the Cloud.AWS.EC2.Instance resource type.

Assign variables.

$ url='https://appliance.domain.com'
$ api_version='2021-07-15'
$ api_version_deployment='2020-08-25'
$ cloud_account_id='14e6b70c-0e76-4c5e-bb61-e6d70a5b43ef'
$ project_id='394a4ccb-22c6-4ef0-8c75-8b77efbefb51'

List all cloud zones.

curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/zones?apiVersion=$api_version"  | jq "."

A snippet of the response shows the cloud account ID with the external region ID and cloud zone ID.

...
      "externalRegionId": "eu-west-1",
      "cloudAccountId": "14e6b70c-0e76-4c5e-bb61-e6d70a5b43ef",
      "name": "AWS / eu-west-1-changed",
      "description": "test description",
      "id": "f32a30fd-67ac-43e3-9512-60cf6ef7bee8"
...

Assign the external region ID variable.

$ external_region_id='eu-west-1'

Assign the cloud zone placement variable.

$ placement_name='/iaas/api/zone/f32a30fd-67ac-43e3-9512-60cf6ef7bee8'

To list the fabric images in your cloud account and zone, specify the cloud account ID and external region ID in the request.

curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" \
    "$url/iaas/api/fabric-images/?apiVersion=$api_version&"\
    '$filter'="(((externalRegionId eq '') or (externalRegionId eq '$external_region_id')) \
    and ((cloudAccountId ne '*') or cloudAccountId eq '$cloud_account_id')))" | jq "."

Examine the response to find the image ID that you want.

...      
      "externalRegionId": "eu-west-1",
      "isPrivate": false,
      "externalId": "ami-9a9012e9",
...

To list the fabric flavors in your cloud account and zone, specify the cloud account ID and external region ID in the request.

curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" \ 
    "$url/iaas/api/fabric-flavors/?apiVersion=$api_version&"\
    '$filter'="(((externalRegionId eq '') or (externalRegionId eq '$external_region_id')) \
    and ((cloudAccountId ne '*') or cloudAccountId eq '$cloud_account_id')))" | jq "."

Examine the response to find the flavor ID that you want.

...          {
      "id": "x1e.xlarge",
      "name": "x1e.xlarge",
      "cpuCount": 4,
      "memoryInMB": 124928,
      "storageType": "ssd",
      "dataDiskSizeInMB": 122880,
      "dataDiskMaxCount": 1,
      "networkType": "Up to 10 Gigabit"
    },
...

Assign the resource type for the VM.

$ resource_type = 'Cloud.AWS.EC2.Instance'

To deploy the VM, assign variables for image and flavor.

$ image_name='ami-9a9012e9'
$ flavor_name='x1e.xlarge'

Create and deploy the VM.

curl -X POST \
  $url/deployment/api/resources?apiVersion=$api_version_deployment \
  -H "Authorization: Bearer $access_token" \
  -H "Content-Type: application/json" \
  -d '{
    "name":"cloud_machine_1",
    "projectId": "'$project_id'",
    "type":"'$resource_type'",
    "properties":{
        "imageRef": "'$image_name",
        "flavor": "'$flavor_name",
        "placement": "'$placement_name'"
  },
}' | jq "."

The response shows the deployment ID.

{
    "deploymentId": "fccd2081-fd44-44c8-878c-f962ef71969a",
    "projectId": "394a4ccb-22c6-4ef0-8c75-8b77efbefb51",
    "requestId": "1f8f2e4f-0b2e-448d-8439-f1a05b1e90c1",
    "resourceId": "9a510ccb-0543-47e8-a2f2-f1f65fcd0b0a"
}

Assign the deployment ID variable.

$ deployment_id='fccd2081-fd44-44c8-878c-f962ef71969a'

Get the status of the deployment.

$ curl -X GET \
  $url/deployment/api/deployments/$deployment_id?apiVersion=$api_version" 
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows the deployment status.

...
  ],
  "status": "CREATE_SUCCESSFUL"
}