This Terraform project provide an example for a simple Virtual Provate Cloud (VPC) example with one virtual mashine. It based on IBM Cloud (cloud.ibm.com) with Infrastructure as Code (IaC). You can use the Terraform example native with Comand line, or use the IBM Cloud Schematics solution without local installation.
If you have no IBM Cloud Account, please start with following pre-requsit:
- Setup an IBM Cloud Account at
- define a Ressource Group in IAM like: resource-vpc-space
- define your ssh key for VPC infrastrucre: like: user-ssh. If you use both VPC generations, it is necessary to define it twice.
- define an IBM Cloud API key:
Using the IBM Schematics service, it is not necessary to install Terraform, CLI on you local mashine. You can use it integrated in IBM Cloud Web GUI. A workspace can be added in Schematics with direct connection to GitHuB to access the Terrform definition.
If you have logon into IBM Cloud Account, switch to Schematics and define your Workspace. Therfore you have define the Workspace name, use your Resource group and add the GitHub URL like https://github.com/JoachimFischer/IBM-vpc-Terraform
Now push the button "Retrieve input variables" to add your API key and the stored SSH name. The information about your API key are available in IAM menue under API Key for classic infrastructure. Now you can creat the workspace. Before starting, please add your SSH key in VPC Infrastructure. THis SSH-key name is added to requesting varibale.
After adding the variable values, use the button of Terraform function. At first push the button "Generate plan". If this is finalized with no error you can "Apply plan". In this step the installation of the ressources are realized. During the activities you can follow the log view.
With the IBM-vpc-Terraform example, you can deploy following architecture:
- One VPC in Frankfurt or Dallas
- One Address Prefix in Frankfurt02 or Dallas1 data center with 172.21.0.0/21
- One SubNet vpc-space-eu-de-1-server in Frankfurt or Dallas with 172.21.0.0/24
- One VSI in Frankfurt servername-eu-de-1
- One Floating IP
- One Public Gateway
- One VPN Gateway with a VPC IPSec Connection (optional)
After the infrastructure is deployed you can test it. Logon into the server: $ssh root@server-ip
It is only possible to access the server via SSH. Therefore only port 22 is allowed.
With IBM Schematics, it is very easy to switch between VPC flavours. So, please validate the list via CLI comand:
$ibmcloud is instance-profiles
To switch the region to Frankfurt eu-de use following CLI:
$ibmcloud target -r eu-de
The default flavor is: cx2-2x4
It is also possible to get the information of available images out of Cloud CLI with following comand:
$ibmcloud is images
It is not necessary to install the IBM CLI local, you can use the IBM Cloud Shell out of the Web GUI. If you have logon to the Cloud portal, you find the symbole in the top menue on the right side.
The variables.tf contain the mapping information.