Terraform™: Quick Start
Download BinariesThe README document within the package provides a detailed overview of using the product.
Terraform integrates with EC2 and vShpere to spin up new VMs in their own virtual network. The configuration for this network is specified by an XML file. XML file tells us the locations of the machine templates (called images in EC2, templates in vSphere), how many VMs of each type, and details about the network to make.
Example
To create an environment in vSphere with a virtual router, two application servers and a database server, you would define it thusly:
<?xml version="1.0" encoding="UTF-8"?>
<context
xmlns="com.urbancode.terraform.tasks.vmware">
<environment
name="terra-env"
folder-name="terra-folder">
<network network-name="my-net-web" port-count="32"/>
<security-group name="default-group">
<port-range first-port="22" last-port="22"/>
<port-range first-port="80" last-port="80"/>
<port-range first-port="3306" last-port="3306"/>
<port-range first-port="8080" last-port="9090"/>
</security-group>
<clone instance-name="router-1"
order="1"
image-path="/mydatacenter/myimagefolder/router-image"
snapshot-name="my-snapshot">
<network-ref network-name="my-net-web" nic-index="1"/>
<post-create-task/>
<event-listener/>
</clone>
<clone instance-name="app-instance-1"
order="2"
image-path="/mydatacenter/myimagefolder/linux-clone-image"
snapshot-name="my-snapshot"
assign-host-ip="true"
server-count="2">
<security-group-ref name="default-group"/>
<network-ref network-name="my-net-web" nic-index="0"/>
</clone>
<clone instance-name="db-instance-1"
order="2"
image-path="/mydatacenter/myimagefolder/linux-clone-image"
snapshot-name="my-snapshot"
assign-host-ip="true"
server-count="1">
<security-group-ref name="default-group"/>
<network-ref network-name="my-net-web" nic-index="0"/>
</clone>
</environment>
</context>
Create an Environment Instance
terraform create vmware-template.xml vmware-1.key datacenter=my-datacenter host.name=my-host.mysite.com \ datastore=my-datastore destination=path/to/ my-destination/folder
Destroy an instance
terraform destroy terra-env-1234.xml vmware-1.key
The second argument relects the xml instance file generated when you created your instance (NOT the original template). No properties are required to destroy an instance.
This command will power down the VMs, delete them, delete the folder that Terraform created, and delete any virtual switches it created.
