Skip to content

Section 9: Deploying Auto Scaling Group using Terraform

In this section, you will use the Cloud9 Terraform workstation deployed in Section 8 to download the Fortinet AWS Terraform modules and update the Terraform variables so FortiGate-VM instances launched by the Auto Scaling Group can register with FortiManager.

Cloud9 is used as the Terraform workstation for this lab. Do not use AWS Cloud9 for this section.


Objectives

By the end of this section, you will be able to:

  • Open the Cloud9 Terraform workstation.
  • Confirm AWS account and region access.
  • Download the Fortinet AWS Terraform module package.
  • Edit the terraform.tfvars file for an Auto Scaling Group deployment.
  • Add FortiManager integration variables.
  • Run Terraform initialization and deployment commands from Cloud9.
  • Verify that the Auto Scaling Group deployment is created successfully.

Before You Begin

Confirm that you have completed the previous sections and have the following information from your instructor:

ItemDescriptionExample
Cloud9 environmentCloud9 Terraform workstation deployed in Section 8student01-Cloud9-New-VPC
AWS Console accessAccess to the AWS account used for the labInstructor-provided
AWS regionRegion where the deployment will runeu-central-1
FortiManager IP addressPublic or private IP address of FortiManagerx.x.x.x
FortiManager serial numberFortiManager VM serial numberFMG-VMXXXXXXXXXX
FortiManager registration passwordPassword used for FortiGate registrationFortinet2026!
FortiManager API admin keyAPI key generated from FortiManagerCreated in Section 3
FortiFlex refresh tokenRefresh token provided by the instructor (Column K)Instructor-provided
FortiFlex serial number listFortiFlex tokens will be generated by the instructor (Column J)Instructor-provided
FortiFlex config ID listFortiFlex config ID provided by the instructorInstructor-provided

Important

Use the same AWS region throughout the lab.

For this lab, the AWS region is:

text
eu-central-1

Step 1: Return to the Cloud9 IDE Home Directory

Before cloning the Fortinet repository, return to your Cloud9 home directory.

bash
cd ~

Step 2: Clone the Fortinet AWS Terraform Modules Repository

Clone the Fortinet AWS Terraform modules repository.

bash
cd environment
git clone https://github.com/ozanoguz/aws-ums-hol.git

Step 3: Go to the Auto Scaling Group Example Directory

The Fortinet documentation uses multiple example directories. Change into that example directory.

bash
cd aws-ums-hol/terraform/examples/spk_gwlb_asg_fgt_gwlb_igw

Step 4: Configure the Terraform Variables

Edit the terraform.tfvars file using nano.

bash
nano terraform.tfvars

Values to Configure Before Proceeding

Root Config Section

VariableDescriptionValue
access_keyProvided by instructor (Column F)Example syntax: "AKIAZRGV3E5YVRVCNJ6T"
secret_keyProvided by instructor (Column G)Example syntax: "+Ubf86qMR/cw46hBBt5k3zZVtFAEzPjmuiLkm3Oq"
regionAWS region nameeu-central-1

VPC Section

VariableDescriptionValue
vpc_cidr_blockVPC CIDR block for auto scale group"10.0.0.0/16"
spoke_cidr_listPassword used for FortiGate registration["10.1.0.0/16"]
availability_zonesAWS Availability Zones["eu-central-1a", "eu-central-1b"]

Auto Scale Group Section: fgt_byol_asg Configuration

VariableDescriptionValue
fgt_versionFortiGate version"7.6.7"
license_typeFortiGate license type"byol"
fgt_passwordFortiGate password"Fortinet2026!"
keypair_nameName of the key pair"student01_KEY"
fortiflex_refresh_tokenProvided by instructor (Column K)Example: "EZEuF7at0AujrqiyqyQ9expxw7ZIem"
fortiflex_sn_listMust be empty[""]
fortiflex_configid_listProvided by instructor (Column J)[80066]
user_conf_file_pathMust be empty""

The section above should look like this

Example:

fortiflex_refresh_token = "S2JmqywnQQOdLxvUTsh0BROtSNqz8g" fortiflex_sn_list = [""] fortiflex_configid_list = [80066]

FortiManager Configuration: fmg_integration Section

VariableDescriptionValue
ipFortiManager public IP address["x.x.x.x"]
snFortiManager Serial Number"FMVMELTM24000254"
autoscale_psksecretPre-shared Key"Fortinet2026!"
fmg_passwordFortiManager password"Fortinet2026!"
api_keyCreated in Section 3Example: "15aszaem8ncqedisuwe79rbwizj1waub"

The section above should look like this

Example:

  ## For UMS feature:
  fmg_integration = {
    ip = "35.157.138.234"
    sn = "FMVMELTM24000253"
    fgt_lic_mgmt = "fmg"
    ums = {
      autoscale_psksecret = "fortinet"
      hb_interval = 10
      fmg_password = "Fortinet2026!" # Use only for PAYG type of FOS
      api_key = "njqpnwb7s9ufk78rx8di4ug944tr3rqs"
    }
  }
  # metadata_options = {
  #   http_endpoint               = "enabled"
  #   instance_metadata_tags      = "enabled"
  # }

Auto Scale Group Section: fgt_on_demand_asg Configuration

VariableDescriptionValue
fgt_versionFortiGate version"7.6.7"
license_typeFortiGate license type"on_demand"
fgt_passwordFortiGate password"Fortinet2026!"
keypair_nameName of the key pair"student01_KEY"
user_conf_file_pathMust be empty""

FortiManager Configuration: fmg_integration Section

VariableDescriptionValue
ipFortiManager public IP address["x.x.x.x"]
snFortiManager Serial Number"FMVMELTM24000254"
autoscale_psksecretPre-shared Key"Fortinet2026!"
fmg_passwordFortiManager login password"Fortinet2026!"
api_keyCreated in Section 3Example: "15aszaem8ncqedisuwe79rbwizj1waub"

The section above should look like this

Example:

  ## For UMS feature:
  fmg_integration = {
    ip = "35.157.138.234"
    sn = "FMVMELTM24000253"
    fgt_lic_mgmt = "fmg"
    ums = {
      autoscale_psksecret = "fortinet"
      hb_interval = 10
      fmg_password = "Fortinet2026!" # Use only for PAYG type of FOS
      api_key = "njqpnwb7s9ufk78rx8di4ug944tr3rqs"
    }
  }
  # metadata_options = {
  #   http_endpoint               = "enabled"
  #   instance_metadata_tags      = "enabled"
  # }
    }

}

Save "terraform.tfvars" file using following key combination:

bash
CTRL + X (for Windows users)
or
Command + X (for Mac users)

Step 7: Initialize Terraform

Run Terraform initialization from the example directory.

bash
terraform init

Confirm that Terraform downloads the required providers and modules successfully.


Step 8: Review the Terraform Plan

Generate and review the Terraform execution plan.

bash
terraform plan

Review the resources that Terraform will create or modify.


Step 9: Apply the Terraform Configuration

Deploy the infrastructure.

bash
terraform apply --auto-approve

Terraform will create or update the AWS resources.


Step 10: Verify the Deployment

After Terraform completes, verify the following:

  1. The Auto Scaling Group is created in AWS.
  2. FortiGate-VM instance is launched.
  3. FortiGate-VM instance can reach FortiManager.
  4. FortiGate-VM instance registered with FortiManager.
  5. The FortiManager UMS group receives the expected instance information.

AWS UMS Hands-on Lab Guide