Skip to main content
Manage Terraform resources
Last update:

Manage Terraform resources

All resources created with Terraform are paid for according to the fee-for-service models. Charging for the resource begins after resource creation.

The cost of resources created with Terraform is not different from the cost of resources created with control panel.

Create or modify resources

To add new resources to the infrastructure or modify created resources, you must edit the configuration file. Terraform automatically determines which resources to create, modify, or delete.

If you have made changes through the control panel, they will not appear in the Terraform configuration files.

We recommend that you create resources in order. If you create all resources that are described in the configuration file at once, an error may occur — Terraform creates resources regardless of the order in which they are listed in the file. For more information about creating resources, see the instructions Create resource dependencies Terraform documentation.

  1. Open the CLI.

  2. Make sure you are in the directory with the configuration file.

  3. Add the resources to be created or edit the resource description in the configuration file.

  4. Check that the configuration file has been compiled without errors:

    terraform validate
  5. Format the configuration file:

    terraform fmt
  6. Check the resources that will be created:

    terraform plan
  7. Apply the changes and create the resources:

    terraform apply
  8. Confirm creation — enter yes and press Enter. The changes will be displayed in the control panel.

  9. If there were insufficient quotas to create resources, increase quotas.

Limitations of the resource openstack_compute_flavor_v2

If you change the parameters vcpus, ram or disk in the openstack_compute_flavor_v2 resource description to invalid, then an error will occur — Terraform will delete the resource and will not be able to create a new one.

To create a new flavor first and then delete the old one, add a block to the openstack_compute_flavor_v2 resource description:

lifecycle {
create_before_destroy = true
}

Check out the detailed description of the resource openstack_compute_flavor_v2.

Delete resources

You can delete specific resources or the entire infrastructure that was created using Terraform. Resources created in other ways (for example, in the control panel) will not be deleted.

  1. Make sure you are in the directory with the configuration file.

  2. Remove resources from the configuration file.

  3. Check which resources will be deleted:

    terraform plan
  4. Apply the changes and remove the resources:

    terraform apply
  5. Confirm deletion — enter yes and press Enter. The deleted resources will no longer appear in the Control Panel.