When creating a cloud zone, you can specify a folder with a path that relates to a datacenter, so that when you deploy a machine you deploy it to that folder.

To create a cloud zone with a folder, you first obtain an external region ID with a cloud account ID as input. Only the vSphere, VMC, and VCF cloud accounts support folders. Then you use the Folders API to get the external ID for the folder to specify.

The following procedure shows how to find a folder that you can use when creating a cloud zone.

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.
    Note: Users with the following RBAC permissions can also use the folder API to create a cloud zone:
    • provisioning_cloud-zones_read
    • provisioning_cloud-zones_manage
  • Verify that you have the cloud account ID for the cloud account with the folder that you want to use. See Add a vSphere Cloud Account.

Procedure

  1. Assign the cloud account ID variable.
    cloud_account_id='<your_cloud_account_id>'
  2. List the info for the cloud account.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/cloud-accounts/$cloud_account_id/?apiVersion=$api_version"  | jq "."
  3. To find the region where you want to create a cloud zone, examine the enabledRegions section of the response and note the external region ID and its ID.
  4. Assign the external region ID variable.
    external_region_id='<your_external_region_id>'
    region_id='<your_region_id>'
  5. List all folders associated with the external region and the cloud account.
    curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/folders?externalRegionid=$external_region_id&cloudaccountid=$cloud_account_id/?apiVersion=$api_version"  | jq "."
    Note: Query parameters are optional:
    • By providing the cloud account ID, you filter the folders by cloud account.
    • By providing the external region ID, you filter the folders by datacenter.
  6. Examine the response and note the external ID of the folder that you want to use.
    Any of the folders listed in the response can be used in the cloud specification.
  7. Assign the external ID variable.
    external_id='<your_external_id>'
  8. To create a cloud zone with a folder in the datacenter, specify the external ID as the value for the folder.
    curl -X POST \
      "$url/iaas/api/zones?apiVersion=$api_version" \
      -H 'Content-Type: application/json' \
      -H "Authorization: Bearer $access_token" \
      -d '{ 
        "regionId": "'$region_id'", 
        "name": "<cloud_zone_with_folder>", 
        "folder": "'$external_id'"
      } | jq "."
    The response shows the folder and cloud zone ID.

Results

Any resources that are deployed in the cloud zone are deployed to the folder.

Example: Create a Cloud Zone with a Folder

Assign variables and specify an ID for a vSphere cloud account.

$ url='https://appliance.domain.com'
$ api_version='2021-07-15'
$ cloud_account_id='2636b316-b514-47f3-93b8-78f18df51a29'

List the information for the vSphere cloud account.

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

Examine the response to find the region where you want to create a cloud zone. A snippet of the response shows the enabledRegions with an external region ID and your cloud account ID.

...
"enabledRegions": [
    {
        "externalRegionId": "Datacenter:datacenter-3",
        "name": "SDDC-Datacenter",
        "cloudAccountId": "2636b316-b514-47f3-93b8-78f18df51a29",
        "id": "8d633554-90ca-4f8a-8a0f-1cd3cd90a522",
        "updatedAt": "2022-04-02",
...

Assign the external region ID variable.

$ external_region_id= 'Datacenter:datacenter-3'
$ region_id= '8d633554-90ca-4f8a-8a0f-1cd3cd90a522'

List folders associated with the external region and cloud account.

$ curl -X GET -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" "$url/iaas/api/folders?externalRegionid=$external_region_id&cloudaccountid=$cloud_account_id/?apiVersion=$api_version"  | jq "."

A snippet of the response shows the folders associated with the external region and the cloud account. The external ID is the value that you assign to the folder when creating the cloud zone.

...
        "cloudAccountIds": [
            "2636b316-b514-47f3-93b8-78f18df51a29"
        ]
        "externalId": "dbuyukliiska",
        "name": "dbuyukliiska",
        "id": "3863f2cc-0340-483f-b24e-d351b7c53c8c",
        "createdAt": "2022-04-02",
        "updatedAt": "2022-04-02",
...

Assign the external ID.

$ external_id='dbuyukliiska'

Create a cloud zone with a specified folder.

curl -X POST \
  "$url/iaas/api/zones?apiVersion=$api_version" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $access_token" \
  -d '{ 
    "regionId": "'$region_id'", 
    "name": "Demo-zone-with-folder-1", 
    "folder": "'$external_id'"
  } | jq "."

A snippet of the response from your request shows the folder and cloud zone ID.

...
    "folder": "dbuyukliiska",
    "externalRegionId": "Datacenter:datacenter-3",
    "cloudAccountId": "2636b316-b514-47f3-93b8-78f18df51a29",      
    "name": "Demo-zone-with-folder-1",
    "id": "258bccb1-a337-4b63-9a8a-44a414761d93",
    "updatedAt": "2021-11-22",
...