I recently rebuilt my VMware Cloud Foundation (VCF) lab environment to run the latest VCF 9.0.1 release. While most of the deployment and configuration has been fully automated, I was dreading the VMware Cloud Foundation Automation (VCFA) setup, mainly as the initial configuration can be a bit involved.

Having some experience with configuring VCFA manually, I wanted to take the opportunity to automate as much of the setup as I could, so the next that I need to rebuild, it is not an issue for me, which is typically the case as I like to automate everything!
My automation approach was going to be leveraging the newly published Terraform Provider for VCFA, this was on my todo list but I finally got a chance to play with it over the weekend in my lab.
I was blown away at how the automation was at configuring VCFA, the same manual tasks could easily 20min+ and using the TP4VCFA, it was done in under 30 seconds! 🤯
It has been some time since I had played with Terraform, but once I figured out how the TP4VCFA works, I was able to quickly build a Terraform manifest that would automate all tasks within the Provider Portal and some of the initial Organization Portal setup as well. The TP4VCFA has Provider and Tenant module that respectively applies to the VCFA Provider and Tenant Portal configurations.
Step 1 - Clone the TP4VCFA repo and change into the provider directory
git clone https://github.com/vmware/terraform-provider-vcfa.git cd terraform-provider-vcfa/examples/greenfield/provider
Step 2 - The directory includes a number of sample manifests demonstrating how to use each resource type, go ahead and move anything that does NOT end with _variables.tf to another folder, since it will attempt to apply those examples if you are using the current working directory.
Download my sample manifests:
- vcfa-provider-example-main.tf
- vcfa-provider-example-terraform.tfvars
- vcfa-provider-example-william_custom_variables.tf
and store them into the current working directory, so it looks like the following:

The main.tf defines the various VCFA resources that it must be created and/or fetched, which has comments for users to understand what it is doing. The custom_variables.tf is my own custom variables manifest for making it easier to describe my VCFA configuration, such that I can easily use the TP4VCFA and is referenced at the bottom of the terraform.tfvars file, so you know which variables are coming from where.
You only need to modify terraform.tfvars to match your VCFA deployment, the assumption is that nothing has been setup in the VCFA Provider Portal, but you have all the prerequisite met (e.g. VCF Networking enabled with VPC and vSphere Supervisor configured with VPC). If you are unsure, please refer to this blog post here and here before proceeding.
Step 3 - Perform the init operation, which will install the required modules.
terraform init
Step 4 - Next run the plan operation, which will validate your environment and the desired state and output any errors or if everything was setup correctly, you something like the following outline the resources that will be created in your VCFA setup.
terraform plan

Step 5 - Finally, run the apply operation, which will start
terraform apply or terraform apply -auto-approve

As you can see from the screenshot, the entire VCFA Provider Portal configuration took ~25 seconds to complete! The ~hour-ish investment was totally worth it 😁
Thanks for the comment!