시작하기 전에
- 실습에서는 정해진 기간 동안 Google Cloud 프로젝트와 리소스를 만듭니다.
- 실습에는 시간 제한이 있으며 일시중지 기능이 없습니다. 실습을 종료하면 처음부터 다시 시작해야 합니다.
- 화면 왼쪽 상단에서 실습 시작을 클릭하여 시작합니다.
In this lab you'll learn how to leverage terraform module published in Fortinet's GitHub repository to deploy an HA cluster of FortiGates in Google Cloud.
Terraform modules are convenient for grouping resources deployed together. They allow to keep your code clean by providing an abstraction layer to a block of code/resources. Fortinet terraform module for FortiGate HA cluster includes all necessary elements like addresses, load balancers and Cloud NAT and bootstraps FortiGate configuration for easy deployment. This lab will guide you through most common deployment using the module hosted on GitHub.
The recommended architecture for deploying FortiGate appliances in Google Cloud is an active-passive HA cluster of two appliances with an external and internal pass-through network load balancer directing the traffic to the currently active instance. Both instances will be deployed with four network interfaces: one external, one internal, one reserved for HA cluster synchronization and one dedicated for management. For more details on the recommended architecture and the use-cases please refer to FortiGate architecture in Google Cloud.
Before you start completing the lab tasks it is worth spending a moment learning your lab environment and consoles. You can skip this part if you are already familiar with Fortinet Qwiklabs.
Qwiklabs environment will create a dedicated temporary access to the Google Cloud for you. You do not need your own accout to complete the labs. The environment will be available for a limited time - there is no possibility to pause the lab so make sure you have time to complete it. If you don't make it - don't worry, you can start the lab again later.
The webpage you are reading right now is your Lab Console. You will find the instructions how to complete each step here. On the right you can find navigation frame with links to individual sections of the lab. After you start the lab, on the left side under the Start Lab / End Lab button you will find the time left for the lab, a button opening your GCP Console and a series of information you will need to complete the lab. Start your lab now if you haven't done so yet.
Clicking the Open Console button on top left will open a new browser tab with Google login form. Use the
On the left you will find a list of all services available in GCP which can be toggled on and off using the "burger menu" icon in the top-left corner. Commonly used in Fortinet labs are Compute Engine, VPC network, and Network services. The latter is not visible in the default view and can be found after expanding the list using MORE PRODUCTS link at the bottom. Feel free to use pin / unpin button visible after hovering over list elements to build your own list of most used services.
Products, individual resources and documentation can be also easily found using the search bar located at the top of the screen.
FortiGate virtual appliances can be managed using web GUI available over HTTPS protocol on the default port or using command line interface in GUI or via SSH. Configuration of FortiGate HA cluster is managed only using the primary instance and automatically replicated to secondary instance. Secondary instance management console can be optionally accessed using its public IP address to verify the clustering and replication status.
While there are several ways to run terraform, the simplest one is to use the command-line. If you are new to deploying cloud infrastructure using code we recommend using Cloud Shell, which comes preinstalled with the gcloud CLI, Git, Terraform, and text editors. If you use Cloud Shell, you don't need to install anything on your workstation. Cloud Shell can be accessed within the Cloud Console or in a separate browser tab or window. In order to use the To use Cloud Shell Cloud Shell editor and terminal at the same time open https://shell.cloud.google.com in a new browser tab.:
While there are several ways to run terraform, the simplest one is to use the command-line. If you are new to deploying cloud infrastructure using code we recommend using Cloud Shell, which comes preinstalled with the gcloud CLI, Git, Terraform, and text editors. If you use Cloud Shell, you don't need to install anything on your workstation. Cloud Shell can be accessed within the Cloud Console or in a separate browser tab or window. In order to use the Cloud Shell editor and terminal at the same time open https://shell.cloud.google.com in a new browser tab.
Terraform merges and deploys all *.tf files in the current working directory (folder), but it’s convenient to split the code into multiple files for better readability. You will create a new directory and use multiple files following the best practices which recommend putting resources, output, and variables into separate files (see Best practices for general style and structure for more details on terraform guidelines). You will leverage gcloud authentication to configure Google Terraform provider. This way you do not need the explicit provider block in your code (you may still create it though for the code clarity). For alternative ways of authenticating terraform to Google Cloud consult the terraform provider documentation.
It is recommended to use input variables to store any values that might change between deployments or which are used in multiple places. This way you will be able to re-use the same terraform code in different environments by only changing variable values. Variables are typically declared in variables.tf file and their values can be passed using command-line, environment variables, file or deployment tool like Terraform Cloud. You will use terraform.tfvars file to assign values to variables.
Open variables.tf file in editor and declare set of basic inputs for the FortiGate module:
Next, open terraform.tfvars file and assign values to your variables replacing the sample values below:
For project_id use prefix use a string of your choice.
This lab subnets are deployed in region argument, for production deployments it is recommended to indicate zones explicitly using the zones argument instead and avoid excessive inter-zonal traffic. To find the available zones you can use the following gcloud command (replace "MY_REGION" with region of your lab):
Create a list of 2 different zones in the same region and save it as a value of an input variable in terraform.tfvars, eg. for “europe-west2” region you could choose:
Open the main.tf file and start by adding an optional provider block and configuring terraform to use your Google Cloud project. You can use project_id variable you set earlier:
In main.tf file create a module block for FortiGate cluster and indicate source of the module published in Fortinet GitHub account:
Indicate zones where to deploy using input variable and list the subnet names you want to connect your cluster to.
The subnets "external", "internal", "hasync", and "mgmt" were already created for this lab. You can find them in cloud console or using command below (optional filter will hide subnets from the default VPC):
If you need to deploy less or more network interfaces you can easily do so by providing a shorter or longer list of subnets in subnets argument. See 3-nic-basic and 8-nic-basic examples in GitHub repository for a sample code.
The following arguments are not obligatory for the module to work, but allow fine control over the configuration of your cluster. For the full list of the module input variables consult the documentation of the module and variables.tf file available in GitHub repository.
To configure the virtual machine type and the firmware version use the machine_type and image arguments:
Keep in mind the requirements regarding vCPUs related to the number of network interfaces (4 NICs require a machine type with at least 4 vCPUs).
This module accepts flexible inputs regarding base images - you can use versions (also in shorter branch notation) with licencing type, family names and explicit image names. You can find more details in the module documentation.
In this lab you are using a PAYG (Pay As You Go) licensing. To use BYOL (Bring Your Own License) image, which requires license files or FortiFlex activation tokens, change the image.license argument from "payg" to "byol". You can license the cluster during bootstrapping by providing license file names:
or using FortiFlex tokens:
As the module creates external load balancer forwarding rules for the public traffic you can define your addresses using frontends argument. Eg.
will reserve 2 external addresses, connect them to external network pass-through load balancer (ELB) and redirect all ports (L3_DEFAULT) to FortiGates. FortiGates will be preconfigured with VIP pools matching the addresses.
FortiGate uses its linked service account to synchronize metadata information about Compute resources. By default the module will use the Default Compute Engine Service Account, but you should use a dedicated one (see the "FortiGate: Fabric Connector for Google Cloud" lab for more details). In this lab the service account was already created, indicate it in service_account argument (replacing "PROJECT_ID" with your real project id:
Lastly, make sure the resources are named and labeled according to your organizational standard using prefix and labels arguments:
Your code should now look similar to below:
Terraform can show values related to created resources to streamline the workflow. In this case it would be useful to know the management address of the deployed firewalls and the initial admin password. As you are using a module to deploy resources you have to use the outputs made available by the module itself.
Open outputs.tf file which is usually used to declare outputs and add the following code:
In the terminal window make sure you are in the directory with your template code and run the following command to download all necessary terraform modules and providers:
At this point you are ready to deploy the infrastructure. Run the following command
you will be presented with the full list of all resources terraform will create, confirm the operation by typing “yes”. Terraform will now create all resources included in the FortiGate module.
Use the management IP address of primary FortiGate and initial admin password from terraform outputs to connect using SSH:
Note that you might need to wait a few minutes before FortiGates fully provision. You can check the VMs serial console output in Google Cloud web console to monitor the progress.
After connecting for the first time you will be asked to change your password:
Verify the status of the provisioning by checking the output of the following command:
The output should resemble the following:
At the end of the output, you should see two instances: Primary and Secondary. This output confirms that both instances were licensed properly and successfully formed an HA cluster.
Note: The secondary instance might initially show up as out-of-sync, further deployment and configuration steps can continue regardless.
The last step is cleaning up and deleting all resources that were created in the tutorial.
Delete the FortiGate and the remaining resources:
Go to the deployment directory in Cloud Shell terminal and run the following command:
Confirm you want to delete the resources by typing "yes".
현재 이 콘텐츠를 이용할 수 없습니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
감사합니다
이용할 수 있게 되면 이메일로 알려드리겠습니다.
한 번에 실습 1개만 가능
모든 기존 실습을 종료하고 이 실습을 시작할지 확인하세요.