My notes and ramblings, normally about automation

PowerCLI - VMware Cloud on AWS - Deploy One Host SDDC

· Read in about 3 min · (616 Words)
PowerCLI VMware AWS

The latest release of VMware Cloud on AWS introduces a brand-new deployment configuration. We can now deploy an SDDC which consists of a single host! This is exciting for many reasons, but biggest reason for me is being able to access all the APIs without occupying the standard minimum SDDC footprint of four hosts. More information on the One Host release is available here: VMware Cloud on AWS – Single Host Access

We’re going to take a quick look at how we can quickly and easily deploy one of these 1 host SDDCs with PowerCLI.

AWS Customer Account Linking

If this is the first time you’re deploying an SDDC, you will need to link your AWS account to the VMware Cloud on AWS service. This linking allows us to do many things but, for the purpose of an SDDC deployment, it will allow us to connect our SDDC to our existing AWS VPC. The easiest way to create this link is by logging in to the VMware Cloud on AWS Cloud Console, heading to the ‘Developer Center’ tab from the top menu, then the ‘API Explorer’ sub-tab. We will then want to expand the ‘AWS Account Connection Operations’ section, followed by also expanding the ‘GET /orgs/{org}/account-link’ section. After verifying the ‘org’ parameter already has a value set, click the ‘Execute’ button.

VMWonAWS - Account Linking API Usage

We’ll want to then copy the URL associated with the ‘template_execution_url’ and paste it into our browser of choice. This URL take us to AWS’ CloudFormation service and run through a template that will configure the account linking on our behalf.

VMWonAWS - Account Linking API Usage

We’re now ready to start deploying our SDDC with the method of our choice!

PowerCLI Deployment

PowerCLI has the ability to interact with the VMware Cloud on AWS APIs through a low-level, API access only, module. The following script makes the process of deploying a single node SDDC easy and straightforward. Download the sample script below, update lines 9 through 12 with values for your environment, and run the script!

# Author: Kyle Ruddy
# Product: VMware Cloud on AWS
# Description: VMware Cloud on AWS Single Host Deployment Script using PowerCLI
# Requirements:
#  - PowerShell 3.x or newer
#  - PowerCLI 6.5.4 or newer

# Set details for SDDC
$oauthToken = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
$sddcName = "PowerCLI-1Node-SDDC"
$hostCount = "1"
$awsRegion = "US_WEST_2"

# --- Deployment code  ---
# Connect to VMware Cloud Service
Connect-Vmc -RefreshToken $oauthToken | Out-Null

# Get ORG ID
$orgSvc = Get-VmcService -Name com.vmware.vmc.orgs
$org = $orgSvc.List()
Write-Host "Org:"$org.display_name" ID:"$org.id

# Get Linked Account ID
$connAcctSvc = Get-VmcService -Name com.vmware.vmc.orgs.account_link.connected_accounts
$connAcctId = $connAcctSvc.get($org.id) | Select-Object -ExpandProperty id
Write-Host "Account ID: $connAcctId"

# Get Subnet ID
$compSubnetSvc = Get-VmcService -Name com.vmware.vmc.orgs.account_link.compatible_subnets
$vpcMap = $compSubnetSvc.Get($org.id, $connAcctId, $region) | Select-Object -ExpandProperty vpc_map 
$compSubnets = $vpcMap | Select-Object -ExpandProperty Values | Select-Object -ExpandProperty subnets
$compSubnet = $compSubnets | where {$_.name -ne $null} | Select-Object -first 1
Write-Host "Subnet CIDR"$compSubnet.subnet_cidr_block"ID:"$compSubnet.subnet_id

# Deploy the SDDC
$sddcSvc = Get-VmcService com.vmware.vmc.orgs.sddcs
$sddcCreateSpec = $sddcSvc.Help.create.sddc_config.Create()
$sddcCreateSpec.region = $awsRegion
$sddcCreateSpec.Name = $sddcName
$sddcCreateSpec.num_hosts = $hostCount
if ($org.properties.values.sddcTypes) {$sddcCreateSpec.sddc_type = "1NODE"}
$sddcCreateSpec.Provider = "AWS"
$accountLinkSpec = $sddcSvc.Help.create.sddc_config.account_link_sddc_config.Element.Create()
$accountLinkSpec.connected_account_id = $connAcctId
$custSubId0 = $sddcSvc.Help.create.sddc_config.account_link_sddc_config.Element.customer_subnet_ids.Element.Create()
$custSubId0 = $compSubnet.subnet_id
$accountLinkSpec.customer_subnet_ids.Add($custSubId0) | Out-Null
$sddcCreateSpec.account_link_sddc_config.Add($accountLinkSpec) | Out-Null
$sddcCreateSpec
$newSddc = $sddcSvc.create($org.Id, $sddcCreateSpec)
$newSddc

The script can also be found on the VMware Code Sample Exchange site: VMware on AWS - 1 Node SDDC Deployment

Summary

The latest update to VMware Cloud on AWS brings a great new way to access all the features, services, and APIs the service has available, just in a smaller footprint. These one host SDDCs can be deployed and managed the same way as standard SDDCs. This blog post took a look at how to use PowerCLI to deploy this new configuration.