VMware Cloud on AWS Code Samples

One of the(many) great things about VMware Cloud on AWS, is the operational consistency it provides between your on-prem and public cloud environments.  Be sure to check out this recent blog post for some more! Top 10 coolest features of VMware Cloud on AWS

For example, you can easily leverage tools such as PowerCLI to manage and automate your shiny new VMC on AWS SDDC.  However to manage the VMC environment itself you’ll need an API Token(aka Refresh Token), rather than connect with the Connect-VIServer cmdlet.

In this post, you’ll see you how to leverage Code Sample’s within the Developer Center to get up and running quickly. We’ll download a sample script to export tasks from VMware Cloud on AWS to a CSV file.  Which could be used for auditing purposes.

NOTE, these steps assume that you already have a SDDC deployed within VMC on AWS.

  1. First things first,  login to https://console.cloud.vmware.com
  2. Launch VMware Cloud on AWS

    VMC-1

  3. Click Developer Center, followed by Code Samples

    VMC-5

  4. You will be presented with several code samples from various categories.  e.g. PowerShell, Python, REST, Terraform etc.  Within the Filter Samples search bar type export, then Download the Export VMC Tasks to CSV sample

    VMC-6

  5. Now we need to need to get our API Token. In the top right, click the down arrow
    next to your name in the top right hand corner, and My Account 

    VMC-2

  6. Click API Tokens. If you don’t already have a token, click New Token then Continue and one will be generated for you.

    VMC-3

  7. This token will be used to authenticate to VMware Cloud on AWS via API. Click Copy to Clipboard

    VMC-4

  8. Next, start a PowerCLI Session.  If you don’t already have PowerCLI installed, start a PowerShell session and enter the following command to install directly from the PowerShell Gallery.
    Install-Module -Name VMware.PowerCLI –Scope CurrentUser
    
  9. Install the VMC module
    Install-Module -name VMware.VMC -scope CurrentUser
    
  10. Navigate to the directory where you downloaded the sample script, and run it
    ./Export-VMC-Tasks.ps1
    
  11. You’ll be prompted for your Refresh Token, paste this in from your clipboard and press Enter. Type a path and filename where you want to export, and press Enter again

    VMC-7

  12. Review the contents of the CSV. You’ll see the various tasks that have been performed at the VMC level

Optionally, take a look at the script to see how to connect with the API token.

Connect-Vmc -RefreshToken $RefreshToken

Take some time to take a look at some of the other Code Samples available.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s