In this blog post, we will discuss how to set up a multizone resiliency environment using Terraform and IBM Cloud services. We will cover the steps to create a Virtual Servers on VPC with auto-scale feature. Reference architecture that we will automatically provision can be found at : https://cloud.ibm.com/docs/pattern-vpc-vsi-multizone-resiliency?topic=pattern-vpc-vsi-multizone-resiliency-web-app-multi-zone
% git clone git@github.ibm.com:client-solutioning/pattern-vpc-vsi-multizone-resiliency.git
Step 2: List available branches
Before we proceed, let's list all available branches in the repository.
% git branch -a
Clone the virtual server autoscale module with specific branch called "init-module"
% git clone --branch init-module https://github.com/terraform-ibm-modules/terraform-ibm-landing-zone-vsi-autoscale.git
Step 3: Update IBM Cloud Plugins
You may need to update IBM Cloud plugins such as VPC infrastructure plugin in my case.
% ibmcloud plugin update vpc-infrastructure
Step 4: Create a Terraform variables file
To pass commonly used parameter values easily, we can create a Terraform variables file called terraform.tfvars. In this file, we can store the API key, public/private SSH key, and other parameters that we will use throughout the deployment process. Otherwise, you need type those information repeatedly when you run `terraform plan` command.
% vi terraform.tfvars
Step 5: Generate SSH public and private keys
We'll generate SSH public and private keys using the "ssh-keygen" command if they haven't been generated previously. These keys are essential for connecting to IBM Cloud services.
$ ssh-keygen -t rsa -b 4096 -C "changwoo.jung@ibm.com"
$ pbcopy < ~/.ssh/id_ed25519.pub
# Copies the contents of the id_ed25519.pub file to your clipboard
(base) changwoojung@Changwoos-MacBook-Pro .ssh % ssh-keygen -t rsa -b 4096 -C "changwoo.jung@ibm.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/changwoojung/.ssh/id_rsa): /Users/changwoojung/.ssh/id_rsa_ibmcloud
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/changwoojung/.ssh/id_rsa_ibmcloud
Your public key has been saved in /Users/changwoojung/.ssh/id_rsa_ibmcloud.pub
You can find SSH public key at ~/.ssh/id_rsa_ibmcloud.pub and SSH private key at ~/.ssh/id_rsa_ibmcloud
After ensuring all necessary files are in place, we'll initialize Terraform using the command terraform init. Following initialization, we'll proceed to plan and apply our deployment using terraform plan and terraform apply, respectively.
Step 6: Initialize Terraform Now that we have all the necessary files, let's initialize Terraform.
% terraform init
Step 7: Plan and apply
% terraform plan
% terraform apply
No comments:
Post a Comment