Running Terraform as part of VMware Cloud Automation

vRealize-Automation-Cloud-Blog

As part of the latest version of VMware Cloud Automation it does now support Terraform as a resource and allows you do map directly to TF files and runtime within VMware Cloud Automation.

VMware Cloud Automation consists of three products. Cloud Assembly, Service Broker and Code Stream. For the purpose of setting up Terraform Integration I only use the two first. The setup consists of, defining an integration against Terraform placed in a GitHub organization where we then link one or more configurations to a Project. Within a Terraform template we can also link variables and output as part of the runtime. So when a user requests a service which will trigger terraform. The user facing request can grab the input, place it into the variable and then Cloud Assembly will the Terraform runtime.

The great part is that this works with any of the Terraform providers. As an example I will show afterwards I have services linked against both Azure and vCloud Director, this can be any provider which Terraform supports. (All Terraform providers, non-certified, available in the Registry, including the ones used to provision VMware resources (e.g., NSX, VMC on AWS, vSphere) will be supported.)

As of now only GitHub and GitLab is supported, but support for Bitbucket is planned down the time.

Now to setup start with Cloud Assembly.

Projects -> New Project -> Define a name and check the mark for this. Then click create.

Next we need to create an Project integration to Github (or GitLab)
Cloud Connections -> GitHub -> Setup an API connection to GitHub, this requries that you create an access token to access GitHub. After you have validated access you can go into Projects.

Then you need to define a GitHub repo where you already have some Terraform Configuraiton files (needs to be placed under a folder not root)

Then go into Design -> New From –> Terraform -> Give it a name and choose the project where you linked the Github repo. Here you will create a service offering as part of the canvas. So you need to define where in the repository the source of the service will reside.

As part of this source code I have also defined a variable in my TF code which then gets displayed in the portal (which we will use in the self-service canvas design afterwards.

Once that is imported you will get back to the canvas. Then click version and mark for Release to the catalog 

Then go into Service Broker and go into Content and policies -> Content Sources -> Add and choose VMware Cloud Templates. Then define a name and choose Source Project to collect the templates from (where the Terraform templates are created) and click validate.

The services should now be available under Content. This allows you to customize what the end-user form should look like if you want, such as hiding content and adding new content.

As an example below I have different services published which points to different Terraform providers and templates.

So by clicking on one of the services I get the self-service UI to provision the VM. When the user clicks submit it will automatically start to run Terraform based upon the configuration, so I can see the actions happening in the backend trough the deployments pane.

So this has been a first intro into use of VMware vCloud Automation with Terraform. Looking forward to seeing how this can be used with other extensible actions and integration points.

You May Also Like

About the Author: Marius Sandbu

Leave a Reply

Your email address will not be published. Required fields are marked *