This repo will help you deploy a Equinix Metal server via Terraform for the first time on a windows machine or a Mac.
This repository is Experimental meaning that it's based on untested ideas or techniques and not yet established or finalized or involves a radically new and innovative style! This means that support is best effort (at best!) and we strongly encourage you to NOT use this in production.
Download the following items for your respective OS
If you have a windows machine you need to create a folder that has a file structure similar to this:
- Folder_Name
- main.tf
- terraform.tfvars.example
- putty.exe
- puttygen.exe
- terraform.exe *Requires being unzipped
If you are using a Mac you'll need fewer files:
- Folder_Name
- main.tf
- terraform.tfvars.example
- terraform *Requires being unzipped
Login to the Equinix Metal UI and click on your picture at the top right corner and choose API Keys. If you already have an API Key with Read/Write permissions, copy the token. If you need one click the green +Add in the top right. Then give it a Description and ensure the permissions are Read/Write. Once that is created, copy the token for later.
Login to the Equinix Metal UI and navigate to the Project you want to deploy your server into. Once on that project choose PROJECT SETTINGS at the top of page. On this page you will see a Project ID that looks similar to 25bc4342-0a9b-4481-b7ca-76e87f5a85be. Copy this for later.
Use the API Key and the Project ID gathered in the previous steps, as well as a DNS Friendly Name (No space, Capitals, or Symbols). Then copy terraform.tfvars.example
to terraform.tfvars
and update these values in your terraform.tfvars file.
Doing this will be different per OS, please follow the instructions for your OS.
Open a command/powershell prompt and navigate to your folder you created in the Downloads section above.
Now you need to use Terraform to download all of the plugins were going to use to deploy our server.
terraform.exe init
Now you need to apply you plan
terraform.exe apply
This will show you an output of what will be created, and you will need to type yes and press enter to deploy your stack.
Open your Terminal application and navigate to the folder you created in the Downloads section above.
Now you need to use Terraform to download all of the plugins were going to use to deploy our server.
./terraform init
Now you need to apply you plan
./terraform apply
This will show you an output of what will be created, and you will need to type yes and press enter to deploy your stack.
Connecting to your server will be different for each OS, follow the instructions for your OS below.
Windows machines don't handle Secure Shell (SSH) natively at all. The makes us need to use third party utilities such as Putty and PuttyGen to work with SSH and SSH Keys respectively.
First we will need to convert the private SSH key into a Putty useable file.
Do this by double clicking on PuttyGen then choosing Load towards the mid-right of the app, and select the file named my_tf_ssh_key (You will need to choose "All Files (*.*)"
in the bottom right to find this file).
You will be prompted that your key Sucessuflly imported. Click OK.
Now choose Save private key (You will be prompted to confirm that you want to save the key without a password, click Yes.)
Save the file into the same folder and name it putty_tf_ssh_key.
Now you can launch Putty and connect to your sever.
Double click on putty.exe type in the IP_Address from the Terraform output.
Now on the left menu expand ssh under Connection and click on Auth.
Now click Browse and choose the putty_tf_ssh_key you created in the previous step.
Now click Open. (You will be prompted to confirm you know this server. Click yes)
Lastly type in your username root and press enter.
Done!
On a Mac connection to a linux server is simpler. Record the IP_Address from the Terraform output once the plan is done running. And use that IP address in the following command:
ssh -i my_tf_ssh_key root@<terraform_ip_address>
Done!