Skip to main content

FPT Cloud provider overview

The FPT Cloud provider (fpt-corp/fptcloud) is the bridge between Terraform and FPT Cloud. The provider calls the FPT Cloud APIs to create, read, update, and delete resources exactly as your configuration describes. This page helps you understand how the provider works before you write your first configuration.

Resources covered in this section​

The guides focus on FPT Cloud Server, FPT Storage, and FPT Network:

GroupResourceData source
Computefptcloud_instance, fptcloud_instance_group, fptcloud_ssh_key, fptcloud_snapshotfptcloud_instance, fptcloud_instances, fptcloud_flavor, fptcloud_image, fptcloud_instance_group_policy, fptcloud_ssh_key
Storagefptcloud_storagefptcloud_storage, fptcloud_storages, fptcloud_storage_policy
Networkfptcloud_subnet, fptcloud_security_group, fptcloud_security_group_rule, fptcloud_floating_ip, fptcloud_floating_ip_associationfptcloud_vpc, fptcloud_subnet, fptcloud_security_group, fptcloud_floating_ip
Tagfptcloud_taggingfptcloud_tagging

The provider also supports many other services such as FPT Kubernetes Engine, FPT Database Engine, FPT Object Storage, and Load Balancer. The full list of resources and arguments for each version is in the provider reference documentation.

How the provider identifies your resources​

Each time it calls the API, the provider uses three pieces of information:

  • Token — identifies who you are. The Token has the same permissions as your account on Portal, so Terraform cannot do more than you can do on Portal.
  • Tenant (tenant_name) — the organization that holds the resources, which is the tenant you select at the top of Portal.
  • VPC (vpc_id) — most resources belong to a VPC. You look up the VPC ID by name with the fptcloud_vpc data source.

The provider region argument is used only by some services such as FPT Kubernetes Engine and FPT Database Engine. Instances, disks, and networks follow vpc_id. Even so, always set region to the Region of your VPC so that your configuration keeps working when you add those services.

In-place changes and changes that recreate a resource​

When you edit the configuration, Terraform handles the change in one of three ways:

Symbol in the planMeaning
~ update in-placeThe resource is updated and keeps its data. Examples: renaming an Instance, increasing disk size.
-/+ ... must be replacedThe resource is deleted and then created again. The line that causes this is annotated with # forces replacement.
No change at allThe argument is used only when the resource is created, for example private_ip of an Instance. Editing it after creation has no effect.
danger

When an Instance is recreated, its root disk and all data on it are deleted. For fptcloud_instance, changing vpc_id, subnet_id, image_name, ssh_key, or password recreates the Instance. Always read the plan before you apply.

Managing resources with both Terraform and Portal​

  • Terraform manages only the resources in its state. Resources you create on Portal are not touched by Terraform unless you import them.
  • If you change a Terraform-managed resource on Portal, the next terraform plan reports the difference and terraform apply brings the resource back to the configuration.
  • Choose a single place to change each resource, either Terraform or Portal, so that the two do not overwrite each other.

Provider versions​

The provider is updated frequently. Pin the version in the required_providers block and read the changelog before you upgrade:

terraform {
required_providers {
fptcloud = {
source = "fpt-corp/fptcloud"
version = "~> 0.3"
}
}
}

~> 0.3 allows any 0.3.x release but does not upgrade to 0.4 automatically. For tighter control, set a specific version, for example version = "0.3.90".

Next steps​