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.
-
Open the CLI.
-
Make sure you are in the directory with the configuration file.
-
Add the resources to be created or edit the resource description in the configuration file.
-
Check that the configuration file has been compiled without errors:
terraform validate
-
Format the configuration file:
terraform fmt
-
Check the resources that will be created:
terraform plan
-
Apply the changes and create the resources:
terraform apply
-
Confirm creation — enter yes and press Enter. The changes will be displayed in the control panel.
-
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.
Delete resource
Remove all infrastructure
-
Make sure you are in the directory with the configuration file.
-
Remove resources from the configuration file.
-
Check which resources will be deleted:
terraform plan
-
Apply the changes and remove the resources:
terraform apply
-
Confirm deletion — enter yes and press Enter. The deleted resources will no longer appear in the Control Panel.
Deleting with this method will remove all resources described in all files within the directory.
-
Make sure you are in the directory with the configuration file.
-
Remove all resources:
terraform destroy
-
Confirm deletion — enter yes and press Enter. The deleted resources will no longer appear in the Control Panel.