Create a Software Defined Data Center using VMware Cloud on AWS APIs

Gilles Chekroun
Lead NSX Systems Engineer - VMware Europe
---

I like APIs very much. I was using Amazon Alexa and Lambda functions to demonstrate the power of VMware Cloud on AWS APIs
In this article, let's see how we can use the APIs to create an SDDC from scratch.
Since I am using Python, it will be easy to ask Alexa to do it as well !!

Login to VMware Cloud Services

Follow the URL https://console.cloud.vmware.com and login using your VMware ID.

Open the VMware Cloud on AWS tile
Check existing Organization

Pre-requisites

Before we can do anything with VMware Cloud APIs we need a number of parameters.
  • Org ID
  • Refresh-Token
We will also need to link our AWS account to the VMware Cloud environment to benefit from the ENI interconnection to the native AWS services.
  • Connected Account ID

Org ID

On the top right side we can see the Organization ID
There are 2 descriptors for Org ID: a shot one with 8 characters and a long one with 32
We will need the long one. Just click on the short ID to see the long one and vice-versa.

Refresh Token

On the right side, click on "OAuth Refresh Token"
Generate a new one if not present or make a note of the existing one

AWS account Linking

One of the very first step in deploying an SDDC is to link your AWS account to VMware Cloud. There is a Cloud formation template that will do that for you and allows VMware to create ENI and routing in the VPC you intend to use.

Connected Account ID

We have now our Refresh Token and Org ID. We have linked our AWS account. We need our Connected Account ID now.
To get that we will use yet another API.
In each VMware Cloud on AWS dashboard, there is a Developer Center section and API Explorer tab.
Open the first one "AWS Account Connection Operations" and go down to "Get a list of Connected Accounts"
Insert your Org ID and after execution the API response will give you the Connected Account ID

Examine the Create SDDC API

Back on the Developer Center API Explorer, let's get down to SDDC and "Provision SDDC"
This is a POST operation.

Below the Request Body parameters:
  • "region": "EU_WEST_2"
        • This is the AWS region - here London
  • "num_hosts": "4"
        • This is the number of hosts in your SDDC cluster - min 4
  • "name": "Gilles-API"
        • This is the name of Your SDDC
  • "provider": "AWS"
        • This is the cloud provider.
  • "connected_account_id": "e15f5f10-xxxx-xxxx-9410-f418c64299de"
        • This is the Connected Account ID we got earlier
  • "customer_subnet_ids": ["subnet-85xxxxff"]
        • This is the AWS subnet(s) name in the AZ(s) your will use in your VPC
    • "vxlan_subnet": "10.25.0.0/23"
          • This is the Management Network of your SDDC
    • "deployment_type": "SingleAZ"
          • This is SingleAZ or MultiAZ deployment. MultiAZ will need 2 subnet_ids in 2 AZs
    The Request Body will look like:
    {
       "num_hosts": "4",
       "name": "Gilles-API",
       "provider": "AWS",
        "region": "EU_WEST_2",
        "account_link_sddc_config":
            [
                {
                    "customer_subnet_ids": ["subnet-85xxxxff"],
                    "connected_account_id": "e15f5f10-xxxx-xxxx-9410-f418c64299de"
                }
            ],
        "sddc_type": "",
        "deployment_type": "SingleAZ",
        "vxlan_subnet": "10.25.0.0/23"
    }
    

    Use API to provision the SDDC

    Paste the request body above in the POST 
    SDDC Deployed after 2 hours or so.
    SDDC is attached to AWS VPC

    Simple Python code

    createSDDC function
    
    def createSDDC(org_id, sessiontoken):
    
        myHeader = {'csp-auth-token': sessiontoken}
        myURL = strProdURL + "/vmc/api/orgs/" + org_id + "/sddcs"
        strRequest = {
            "num_hosts": "4",
            "name": "Gilles-API",
            "provider": "AWS",
            "region": "EU_WEST_2",
            "account_link_sddc_config":
                [
                    {
                        "customer_subnet_ids": ["subnet-85xxxxff"],
                        "connected_account_id": "2e381262-xxxx-xxxx-97f4-783437d3a6b4"
                    }
                ],
            "sddc_type": "",
            "deployment_type": "SingleAZ",
            "vxlan_subnet": "10.25.0.0/23"
        }
    
        response = requests.post(myURL, json=strRequest, headers=myHeader)
        jsonResponse = response.json()
    
        if str(response.status_code) != "202":
            print("\nERROR: " + str(jsonResponse['error_messages'][0]))
    
        return
    


    Complete code here.

    Comments

    Populars

    Understanding VMware Cloud on AWS Account Structure and Data Charges

    Create a vCenter Content Library using AWS S3 - Part 2

    Build a VMware Cloud on AWS Content Library using AWS S3