Fortinet white logo
Fortinet white logo

Administration Guide

VM resources

VM resources

There are a couple of FortiFlex VM resources:

fortiflexvm_vms_create

You can create one or more VMs based on a FortiFlex configuration using the fortiflexvm_vms_create resource. This API cannot be used to modify a VM. See fortiflexvm_vms_update for more information.

Example usage

resource "fortiflexvm_vms_create" "example"{
    config_id = 42
    description = "Create through Terraform"
    end_date = "2023-11-11T00:00:00"
    folder_path = "My Assets"
    vm_count = 1
}
Note

Once you declare a resource block and use terraform apply, any modification to this resource block will create new VMs when you use terraform apply again. For example, if you used the resource block in the example above to apply one VM, you will create two more VMs by replacing the value of vm_count with two. Therefore, you will create three VMs in total.

Argument reference

The following arguments are supported:

Argument

Type

Description

config_id

Number (Required)

The ID of the FortiFlex configuration.

description

String (Optional)

The description of the VMs.

end_date

String (Optional)

The VM end date. It cannot be before the current date or after the program's end date. Any format that satisfies ISO 8601 is accepted but the recommended format is YYYY-MM-DDThh:mm:ss.

folder_path

String (Optional)

The folder path of the VMs.

vm_count

Number (Optional)

The number of VMs to be created. The default value is 1.

Attribute reference

The following attribute is exported:

Attribute

Type

Description

id

String

An ID for the resource.

Import

You cannot import this resource.

fortiflexvm_vms_update

You can update, stop, or reactivate a VM, or regenerate a VM token with the fortiflexvm_vms_update resource. By using this resource, you can change the data in the FortiFlex platform immediately. However, it may take several hours for the VMs to update their licenses automatically.

Note

You can use fortiflexvm_vms_create to create VMs. The status of newly created VMs is PENDING. You cannot update a VM if its current status is PENDING. Use a VM token to activate a Virtual Machine before using this API. See Injecting the FortiFlex license for more information.

Example usage

resource "fortiflexvm_vms_update" "example"{
    serial_number = "FGVMMLTM0000XXXX"
    config_id = 42
    description = "Modify through Terraform"
    end_date = "2023-11-11T00:00:00"
    regenerate_token = false
    status = "DISABLE"
}
Note

If you want to update the description or end_date, you must specify the config_id, even if it is unchanged.

Argument reference

The following arguments are supported:

Argument

Type

Description

serial_number

String (Required)

The unique serial number of the VM to be updated.

config_id

Number (Required if you want to update config_id, description, or end_date)

Set a new FortiFlex configuration.

description

String (Optional)

Set a new description.

end_date

String (Optional)

Set a new end date. Any format that satisfies ISO 8601 is accepted but the recommended format is YYYY-MM-DDThh:mm:ss.

regenerate_token

Boolean (Optional)

Defines whether or not to regenerate a new token. If the argument is true, every time you run terraform apply, the system will generate a new token. Set the argument to false if you so not want to regenerate the token anymore.

status

String (Optional)

Set the status as ACTIVE or STOPPED. If you want to use this argument, it is recommended that you also specify the config_id argument.

Attribute reference

The following attribute is exported:

Attribute

Type

Description

id

String

An ID for the resource.

Import

One VM profile can be imported.

To import a VM profile:
  1. Specify the config_id when you configure the provider:

    provider "fortiflexvm" {
        username = "ABCDEFG"
        password = "HIJKLMN"
        import_options= toset(["config_id=42"])
    }
  2. Import the VM profile:

    terraform import fortiflexvm_vms_update.labelname {{serial_number}}

VM resources

VM resources

There are a couple of FortiFlex VM resources:

fortiflexvm_vms_create

You can create one or more VMs based on a FortiFlex configuration using the fortiflexvm_vms_create resource. This API cannot be used to modify a VM. See fortiflexvm_vms_update for more information.

Example usage

resource "fortiflexvm_vms_create" "example"{
    config_id = 42
    description = "Create through Terraform"
    end_date = "2023-11-11T00:00:00"
    folder_path = "My Assets"
    vm_count = 1
}
Note

Once you declare a resource block and use terraform apply, any modification to this resource block will create new VMs when you use terraform apply again. For example, if you used the resource block in the example above to apply one VM, you will create two more VMs by replacing the value of vm_count with two. Therefore, you will create three VMs in total.

Argument reference

The following arguments are supported:

Argument

Type

Description

config_id

Number (Required)

The ID of the FortiFlex configuration.

description

String (Optional)

The description of the VMs.

end_date

String (Optional)

The VM end date. It cannot be before the current date or after the program's end date. Any format that satisfies ISO 8601 is accepted but the recommended format is YYYY-MM-DDThh:mm:ss.

folder_path

String (Optional)

The folder path of the VMs.

vm_count

Number (Optional)

The number of VMs to be created. The default value is 1.

Attribute reference

The following attribute is exported:

Attribute

Type

Description

id

String

An ID for the resource.

Import

You cannot import this resource.

fortiflexvm_vms_update

You can update, stop, or reactivate a VM, or regenerate a VM token with the fortiflexvm_vms_update resource. By using this resource, you can change the data in the FortiFlex platform immediately. However, it may take several hours for the VMs to update their licenses automatically.

Note

You can use fortiflexvm_vms_create to create VMs. The status of newly created VMs is PENDING. You cannot update a VM if its current status is PENDING. Use a VM token to activate a Virtual Machine before using this API. See Injecting the FortiFlex license for more information.

Example usage

resource "fortiflexvm_vms_update" "example"{
    serial_number = "FGVMMLTM0000XXXX"
    config_id = 42
    description = "Modify through Terraform"
    end_date = "2023-11-11T00:00:00"
    regenerate_token = false
    status = "DISABLE"
}
Note

If you want to update the description or end_date, you must specify the config_id, even if it is unchanged.

Argument reference

The following arguments are supported:

Argument

Type

Description

serial_number

String (Required)

The unique serial number of the VM to be updated.

config_id

Number (Required if you want to update config_id, description, or end_date)

Set a new FortiFlex configuration.

description

String (Optional)

Set a new description.

end_date

String (Optional)

Set a new end date. Any format that satisfies ISO 8601 is accepted but the recommended format is YYYY-MM-DDThh:mm:ss.

regenerate_token

Boolean (Optional)

Defines whether or not to regenerate a new token. If the argument is true, every time you run terraform apply, the system will generate a new token. Set the argument to false if you so not want to regenerate the token anymore.

status

String (Optional)

Set the status as ACTIVE or STOPPED. If you want to use this argument, it is recommended that you also specify the config_id argument.

Attribute reference

The following attribute is exported:

Attribute

Type

Description

id

String

An ID for the resource.

Import

One VM profile can be imported.

To import a VM profile:
  1. Specify the config_id when you configure the provider:

    provider "fortiflexvm" {
        username = "ABCDEFG"
        password = "HIJKLMN"
        import_options= toset(["config_id=42"])
    }
  2. Import the VM profile:

    terraform import fortiflexvm_vms_update.labelname {{serial_number}}