To create an image mapping, you make a POST request with a region ID associated with a cloud account. The cloud account can be an AWS, vSphere, Azure, or GCP cloud account.

Cloud vendors use images to configure a VM based on OS settings, such as an ubuntu-16 configuration. When you build a cloud template, you pick an image that fits your needs and map an image name to a value for each account or region. You can also add constraints and configuration scripts to further control resource placement.

The same API calls create an image profile for an AWS, vSphere, Azure, or GCP cloud account. The following example shows how to create an image profile for a vSphere cloud account with the external region ID Datacenter:datacenter-3.

Prerequisites

  • Verify that all general prerequisites and prerequisites for the Automation Assembler Infrastructure as a Service (IaaS) service have been satisfied. See Prerequisites for API Use Case Examples.
  • Verify that you have the cloud account ID for the new cloud account that you added. See Adding Cloud Accounts.

Procedure

  1. Assign the cloud account ID variable.
    cloud_account_id='<your_cloud_account_id>'
  2. Look up region IDs associated with the cloud account and in the external region ID.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/regions/?apiVersion=$api_version&"'$filter'"=externalRegionId%20eq%20'Datacenter:datacenter-3'%20and%20cloudAccountId%20eq%20'"$cloud_account_id"'"  | jq "."
  3. Examine the response to find the ID for the region that you want.
  4. Assign the region ID variable.
    region_id='<your_region_id>'
  5. Create an image profile with an image mapping that specifies the OVA/OVF links.
    curl -X POST \
      $url/iaas/api/image-profiles?apiVersion=$api_version \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{
        "name":"<your_image_profile>",
        "description":"<your_image_profile_description>",
        "imageMapping": {
          "ubuntu": {
             "externalId": "https://cloud-images.ubuntu.com/releases/16.04/release-20220305/ubuntu-16.04-server-cloudimg-amd64.ova"
          }
      },
      "regionId":"'$region_id'"
    }' | jq "."
  6. To obtain the image profile ID, examine the response.

Example: Create image mapping

Assign the required variables including a cloud account ID.
Note: If your organization uses an API service that is hosted outside of the United States, your URL variable must include a country abbreviation. See Regional Endpoints for VMware Aria Automation APIs.
$ url='https://api.mgmt.cloud.vmware.com'
$ api_version='2021-07-15'
$ cloud_account_id='ff4e7585-4197-41fb-89cb-179ef4d24779'

Look up region IDs associated with the cloud account and in the external region ID Datacenter:datacenter-3.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/regions/?apiVersion=$api_version&"'$filter'"=externalRegionId%20eq%20'Datacenter:datacenter-3'%20and%20cloudAccountId%20eq%20'"$cloud_account_id"'"  | jq "."

A snippet of the response shows the region ID.

...                         
          "externalRegionId": "Datacenter:datacenter-3",
          "name": "w01-vc08-DC",
          "cloudAccountId": "ff4e7585-4197-41fb-89cb-179ef4d24779",
          "id": "9b148b38-fc7c-4560-b413-5f47b30e57d8",
...

Assign the region ID.

$ region_id='9b148b38-fc7c-4560-b413-5f47b30e57d8'

Create an image profile named example-image-profile.

$ curl -X POST \
  $url/iaas/api/image-profiles?apiVersion=$api_version \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{
    "name":"example-image-profile",
    "description":"Example image profile",
    "imageMapping": {
      "ubuntu": {
         "externalId": "https://cloud-images.ubuntu.com/releases/16.04/release-20220305/ubuntu-16.04-server-cloudimg-amd64.ova"
      }
    },
    "regionId":"'$region_id'"
  }' | jq "."

A snippet of the response shows the image profile ID.

...        
      "externalRegionId": "Datacenter:datacenter-3",
      "cloudAccountId": "ff4e7585-4197-41fb-89cb-179ef4d24779",
      "name": "example-image-profile",
      "id": "f670fdfc-66d6-4689-9793-d524e7066d1e-9b148b38-fc7c-4560-b413-5f47b30e57d8",
...