Fortinet white logo
Fortinet white logo

Administration Guide

FortiFlexVM Terraform provider

FortiFlexVM Terraform provider

The FortiFlexVM Terraform provider is used to interact with the resources supported by FortiFlexVM. The provider must be configured with the proper credentials before it can be used. See https://registry.terraform.io/providers/fortinetdev/fortiflexvm/latest/docs for more information.

Note

The FortiFlexVM provider requires:

  • A FortiCloud account.

  • FortiFlex registered.

  • An API token. See FortiFlex API.

Example usage

The following is an example of configuring and using the FortiFlexVM provider for a VM:

# Configure the Provider for FortiFlexVM
provider "fortiflexvm" {
    username = "ABCDEFG"
    password = "HIJKLMN"
}

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

Authentication

The FortiFlexVM provider offers a means of providing credentials for authentication. The following methods are supported:

Static credentials

Static credentials can be provided by username and password parameters in the FortiFlexVM provider block.

An example is as follows:

provider "fortiflexvm" {
    username = "ABCDEFG"
    password = "HIJKLMN"
}

Environment variables

You can provide your credentials via the FLEXVM_ACCESS_USERNAME and FLEXVM_ACCESS_PASSWORD environment variables. Setting your FortiFlexVM credentials using static credentials variables will override the environment variables.

An example is as follows:

$ export "FLEXVM_ACCESS_USERNAME"="ABCDEFG"
$ export "FLEXVM_ACCESS_PASSWORD"="HIJKLMN"
Note

If you provide your credentials through environment variables, and the variables contain the character "!", put double quotes around the exclamation mark "!" to avoid the autoescaping problem. For example, if your password is "123!456", please use the command $export "FLEXVM_ACCESS_PASSWORD"="123""!""456".

Then, configure the FortiFlexVM provider as follows:

provider "fortiflexvm" {}

Argument reference

The following arguments are supported:

Argument

Type

Description

username

String (Optional)

This is your username. It must be provided but can also be sourced from the FLEXVM_ACCESS_USERNAME environment variable.
password

String (Optional)

This is your password. It must be provided but can also be sourced from the FLEXVM_ACCESS_PASSWORD environment variable.
import_options

List of objects (Optional)

This parameter is only used for import in some special cases. When the resource to be imported includes the pkg parameter, you need to assign a value.

An example of the supported arguments is as follows:

provider "fortiflexvm" {
    username = "ABCDEFG"
    password = "HIJKLMN"

    import_options = ["pkg=default"]
}

FortiFlexVM Terraform provider

FortiFlexVM Terraform provider

The FortiFlexVM Terraform provider is used to interact with the resources supported by FortiFlexVM. The provider must be configured with the proper credentials before it can be used. See https://registry.terraform.io/providers/fortinetdev/fortiflexvm/latest/docs for more information.

Note

The FortiFlexVM provider requires:

  • A FortiCloud account.

  • FortiFlex registered.

  • An API token. See FortiFlex API.

Example usage

The following is an example of configuring and using the FortiFlexVM provider for a VM:

# Configure the Provider for FortiFlexVM
provider "fortiflexvm" {
    username = "ABCDEFG"
    password = "HIJKLMN"
}

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

Authentication

The FortiFlexVM provider offers a means of providing credentials for authentication. The following methods are supported:

Static credentials

Static credentials can be provided by username and password parameters in the FortiFlexVM provider block.

An example is as follows:

provider "fortiflexvm" {
    username = "ABCDEFG"
    password = "HIJKLMN"
}

Environment variables

You can provide your credentials via the FLEXVM_ACCESS_USERNAME and FLEXVM_ACCESS_PASSWORD environment variables. Setting your FortiFlexVM credentials using static credentials variables will override the environment variables.

An example is as follows:

$ export "FLEXVM_ACCESS_USERNAME"="ABCDEFG"
$ export "FLEXVM_ACCESS_PASSWORD"="HIJKLMN"
Note

If you provide your credentials through environment variables, and the variables contain the character "!", put double quotes around the exclamation mark "!" to avoid the autoescaping problem. For example, if your password is "123!456", please use the command $export "FLEXVM_ACCESS_PASSWORD"="123""!""456".

Then, configure the FortiFlexVM provider as follows:

provider "fortiflexvm" {}

Argument reference

The following arguments are supported:

Argument

Type

Description

username

String (Optional)

This is your username. It must be provided but can also be sourced from the FLEXVM_ACCESS_USERNAME environment variable.
password

String (Optional)

This is your password. It must be provided but can also be sourced from the FLEXVM_ACCESS_PASSWORD environment variable.
import_options

List of objects (Optional)

This parameter is only used for import in some special cases. When the resource to be imported includes the pkg parameter, you need to assign a value.

An example of the supported arguments is as follows:

provider "fortiflexvm" {
    username = "ABCDEFG"
    password = "HIJKLMN"

    import_options = ["pkg=default"]
}