To request a deployment of a cloud template with contents inline, you use the Blueprint APIs to make a POST request with a project ID. Before requesting the deployment, you use the Deployment API to ensure that the deployment name does not already exist.

In this example, you deploy a cloud template by providing contents inline instead of providing a cloud template ID. The new cloud template has different content from previously deployed cloud templates including a load balancer component, a virtual machine component, and a network component. For information about deploying a cloud template by providing a cloud template ID, see Deploy Your Cloud Template.

Prerequisites

  • Verify that all general prerequisites and prerequisites for the Automation Service Broker Deployment service have been satisfied. See Prerequisites for API Use Case Examples.
  • Verify that you have the ID for a project that is associated with the deployment that you are managing. See Request Deployment.
  • Verify that the flavor mapping and image mapping specified in the cloud template to be deployed exist in your cloud account. See Create Flavor Mappings and Create Image Mappings.
  • Verify that the cloud zone that you are deploying into is associated with your project. See Add a Cloud Zone to Your Project.
  • Verify that a network profile is configured for the cloud account associated with the project. See Create Network Profiles.
  • Assign an API version variable for the Blueprint API.
    api_version_blueprint='2019-09-12'
    Note: The Automation Service Broker Deployment service and the Automation Assembler Blueprint service have different API version values. You set the API version value for the Automation Service Broker Deployment service when you satisfied the general prerequisites.

Procedure

  1. Assign the project ID variable.
    project_id='<your_project_id>'
  2. Assign your deployment name variable.
    deployment_name='<your_deployment_name>'
    If your deployment name includes spaces, use double quotes as in the following example.
    deployment_name="This deployment name includes spaces"
    1. To ensure that the deployment name you plan to use does not already exist, list all deployments.
      curl -X GET \
        -G --data-urlencode "name=$deployment_name" \
        $url/deployment/api/deployments?apiVersion=$api_version \
        -H "Authorization: Bearer $access_token" | jq "."
    2. To verify that the deployment name does not already exist, examine the response. If your deployment name appears, create a new name and reassign your deployment name variable.
  3. To deploy a cloud template, assign variables for image mapping and flavor mapping.
    image_mapping='<your_image_mapping_name>'
    flavor_mapping='<your_flavor_mapping_name>'
    

    The image mapping specifies the OS image for a VM. The flavor mapping specifies the CPU count and RAM of a VM.

  4. Request deployment of a cloud template with contents inline.
    curl -X POST \
        $url/blueprint/api/blueprint-requests?apiVersion=$api_version_blueprint \
        -H "Authorization: Bearer $access_token" \
        -H 'Content-Type: application/json' \
        -d '{
          "deploymentName": "'"$deployment_name"'",
          "description": "requesting deployment with contents inline",
          "projectId": "'"$project_id"'",
          "inputs": {
                "flavor": "'"$flavor_mapping"'",
                "image" : "'"$image_mapping"'"
          },
          "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\nresources:\n  cloud-vm:\n    type: Cloud.AWS.EC2.Instance\n    properties:\n      name: cloudvm\n      flavor: '\''${input.flavor}'\''\n      image: '\''${input.image}'\''\n      networks:\n        - name: '\''${resource.Cloud_Network_1.name}'\''\n          network: '\''${resource.Cloud_Network_1.id}'\''\n  Provider_LoadBalancer_1:\n    type: Cloud.LoadBalancer\n    properties:\n      name: OC-LB\n      routes:\n        - protocol: HTTP\n          port: '\''80'\''\n          instanceProtocol: HTTP\n          instancePort: '\''80'\''\n          healthCheckConfiguration:\n            protocol: HTTP\n            port: '\''80'\''\n            urlPath: /index.html\n            intervalSeconds: 60\n            timeoutSeconds: 5\n            unhealthyThreshold: 5\n            healthyThreshold: 2\n      network: '\''${resource.Cloud_Network_1.name}'\''\n      instances:\n        - '\''${resource[\"cloud-vm\"].id}'\''\n      internetFacing: false\n  Cloud_Network_1:\n    type: Cloud.Network\n    properties:\n      name: provider\n      networkType: public\n"
    }' | jq "."
  5. To obtain the cloud template request ID and the deployment ID, examine the response.
  6. Assign the cloud template request ID variable.
    cloud_template_request_id='<your_cloud_template_request_id>'
  7. Get the status of the request.
    curl -X GET \
      $url/blueprint/api/blueprint-requests/$cloud_template_request_id?apiVersion=$api_version_blueprint \
      -H "Authorization: Bearer $access_token" | jq "."

Example: Deploy a Cloud Template with Contents Inline

Request a deployment named Deployment with Cloud Template Contents Inline. When requesting the deployment, set image mapping set to ubuntu and flavor mapping set to small.

Assign variables.

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='2020-08-25'
$ api_version_blueprint='2019-09-12'
$ project_id='394a4ccb-22c6-4ef0-8c75-8b77efbefb51'
$ deployment_name="Deployment with Cloud Template Contents Inline"

To request deployment, you must assign image mapping and flavor mapping variables.

$ image_mapping='ubuntu'
$ flavor_mapping='small'

Request deployment of a cloud template with contents inline.

$ curl -X POST \
    $url/blueprint/api/blueprint-requests?apiVersion=$api_version_blueprint \
    -H "Authorization: Bearer $access_token" \
    -H 'Content-Type: application/json' \
    -d '{
      "deploymentName": "'"$deployment_name"'",
      "description": "requesting deployment with contents inline",
      "projectId": "'"$project_id"'",
      "inputs": {
            "flavor": "'"$flavor_mapping"'",
            "image" : "'"$image_mapping"'"
      },
      "content" : "formatVersion: 1\ninputs:\n  flavor:\n    type: string\n    title: Flavor\n    description: Flavor Mapping Name\n  image:\n    type: string\n    title: Image\n    description: Image Mapping Name\nresources:\n  cloud-vm:\n    type: Cloud.AWS.EC2.Instance\n    properties:\n      name: cloudvm\n      flavor: '\''${input.flavor}'\''\n      image: '\''${input.image}'\''\n      networks:\n        - name: '\''${resource.Cloud_Network_1.name}'\''\n          network: '\''${resource.Cloud_Network_1.id}'\''\n  Provider_LoadBalancer_1:\n    type: Cloud.LoadBalancer\n    properties:\n      name: OC-LB\n      routes:\n        - protocol: HTTP\n          port: '\''80'\''\n          instanceProtocol: HTTP\n          instancePort: '\''80'\''\n          healthCheckConfiguration:\n            protocol: HTTP\n            port: '\''80'\''\n            urlPath: /index.html\n            intervalSeconds: 60\n            timeoutSeconds: 5\n            unhealthyThreshold: 5\n            healthyThreshold: 2\n      network: '\''${resource.Cloud_Network_1.name}'\''\n      instances:\n        - '\''${resource[\"cloud-vm\"].id}'\''\n      internetFacing: false\n  Cloud_Network_1:\n    type: Cloud.Network\n    properties:\n      name: provider\n      networkType: public\n"
}' | jq "."

A snippet of the response provides the cloud template request ID and the deployment ID.

...    
  "type": "blueprint-request",
  "id": "bec37f54-3de5-451d-b484-a110c0ed8772",
...
  "projectId": "394a4ccb-22c6-4ef0-8c75-8b77efbefb51",
  "projectName": "example-project",
  "deploymentId": "5551a299-8b67-45e3-909e-a638d11b0d9f",
  "requestTrackerId": "bec37f54-3de5-451d-b484-a110c0ed8772",
  "deploymentName": "Deployment with Cloud Template Contents inline",
...

Assign the cloud template request ID.

$ cloud_template_request_id='bec37f54-3de5-451d-b484-a110c0ed8772'

Get the deployment status.

$ curl -X GET \
  $url/blueprint/api/blueprint-requests/$cloud_template_request_id?apiVersion=$api_version_blueprint \
  -H "Authorization: Bearer $access_token" | jq "."

A snippet of the response shows the deployment status.

...
  "inputs": {
    "image": "ubuntu",
    "flavor": "small"
  },
  "status": "FINISHED",
...

What to do next

You can use the deployment ID to perform other operations on your deployment. Other operations include, changing the lease on your deployment, fetching deployment resources, reconfiguring a load balancer, or adding a disk to a machine and power it off.