Knowledgebase

How to Provision Cloud Infrastructure on Rcs using Terraform Print

  • 0

Introduction

Terraform is a declarative language that allows you to create, update, and delete infrastructure resources. Instead of writing step-by-step instructions to create resources, Terraform allows you to directly define the resources in a single file. If the resources do not exist yet, Terraform creates new ones. If they exist but the available states don't match with the expected states, Terraform modifies them. This allows you to efficiently manage the infrastructure resources, especially when the infrastructure is large and complicated.

Terraform consists of two main components, the core and provider:

  • The core component reads the configuration files, stores the state for the resources, creates an execution plan, and applies it.
  • The provider component creates methods to interact with various platforms using their APIs such as authentication and authorization, retrieving or manipulating the resources. Every platform has a provider.

This article explains how to provision Rcs Cloud Infrastructure using Terraform. You are to provision multiple resources such as cloud instances, Kubernetes Clusters, and databases using your Rcs Account API key.

Prerequisites

Before you begin:

  • Deploy a Ubuntu server to use a management machine

  • Activate and Copy your Rcs API Key from the Rcs Customer Portal Settings Page

    When enabled, add your management machine IP to the allowed IP subnets list

  • Using SSH, access the server

  • Create as a non-root sudo user

  • Switch to the new sudo user account

      # su sysadmin

    > This article uses the example user sysadmin, replace the username with your actual system user account

  • To use the curl commands in this article, export your Rcs API Key as a system environment variable to use the curl commands in this article

      $ export VULTR_API_KEY="your-vultr-api-key"

Install Terraform

  1. Add the Terraform GPG key to your server

     $ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
  2. Add the official Terraform repository to your APT sources

     $ sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com focal main"
  3. Update the server packages

     $ sudo apt update
  4. Install Terraform on the server

     $ sudo apt install terraform

Install the Rcs Terraform Provider

The Rcs Terraform provider allows you to create infrastructure resources using your Rcs account API key. Install the provider with the correct information as described in the steps below.

  1. Navigate to your user home directory

     $ cd
  2. Create a Terraform workspace to store your resource files

     $ mkdir vultr-terraform
  3. Switch to the new directory

     $ cd vultr-terraform
  4. Using a text editor such as Nano, create a new file provider.tf to store the Rcs provider information

     $ nano provider.tf
  5. Add the following contents to the file

     terraform {
         required_providers {
             vultr = {
                 source = "vultr/vultr"
                 version = "2.15.1"
             }
         }
     }
    
     provider "vultr" {
         api_key = var.VULTR_API_KEY
     }
    
     variable "VULTR_API_KEY" {}

    Save and close the file.

    The above configuration instructs Terraform to use Rcs as the provider with the identifier value vultr/vultr and version 2.15.1. To find the latest version, visit the Rcs Provider GitHub repository.

  6. Create a new file named terraform.tfvars to define your Rcs API key

     $ nano terraform.tfvars
  7. Add the following directive to the file. Replace your_vultr_api_key with your actual value Rcs API key

     VULTR_API_KEY = "your_vultr_api_key"

    Save and close the file.

  8. Initialize Terraform to install the Rcs Terraform provider

     $ terraform init

    When successful, your output should look like the one below:

     Terraform has been successfully initialized!
    
     You may now begin working with Terraform. Try running "terraform plan" to see
     any changes that are required for your infrastructure. All Terraform commands
     should now work.

You have activated and authenticated Terraform to work with your Rcs account. You can define resources and deploy them to your account as you would through the graphical Rcs Customer Portal.

Deploy Rcs Cloud Instances

To deploy Rcs Cloud Instances using Terraform, choose your desired server name, specifications, and region. Then, define the Terraform instance details and apply changes to your Rcs account as described below.

  1. Create a new Terraform resource file vultr_instance.tf

     $ nano vultr_instance.tf
  2. Add the following contents to the file

     resource "vultr_instance" "my_instance" {
         label = "sample-server"
         plan = "vc2-1c-1gb"
         region = "sgp"
         os_id = "387"
         enable_ipv6 = true
     }

    Save and close the file.

    Below is what the above module file defines:

    • vultr_instance: Sets the Rcs resource type you intend to deploy, vultr_instance declares a server instance. Replace the value example_ubuntu_instance with your desired alias to distinguish the instance.

    • label: Specifies the instance label. Replace sample-server with your desired instance name to uniquely identify the resource in your Rcs account.

    • plan: Sets your desired instance specification. vc2-1c-1gb plan matches a Rcs instance with type vc2, 1 vCPU core, and 1 GB RAM. To view a full list of all available plans, visit the Rcs Plans documentation

    • region: Specifies your desired Rcs region to deploy the instance. sgp deploys the instance to the Singapore Rcs location. To view a list of all available regions, visit the Rcs Datacenter locations page and use the short form of a location. For example NJ translates to New Jersey. Use the following command to list the available locations by ID:

        $ curl "https://api.vultr.com/v2/regions" \
          -X GET \
          -H "Authorization: Bearer ${VULTR_API_KEY}"
    • os_id: Sets the instance Operating System (OS) by ID. The value 387 represents Ubuntu 20.04. For a list of all available operating system codes, run the following command:

        $ curl "https://api.vultr.com/v2/plans" \
          -X GET \
          -H "Authorization: Bearer ${VULTR_API_KEY}"
    • enable_ipv6: Enables a public IPV6 address on the Rcs instance

  3. Preview the changes you are about to apply

     $ terraform plan

    Output:

     Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
     + create
    
     Terraform will perform the following actions:
    
     # vultr_instance.example_instance will be created
     + resource "vultr_instance" "example_instance" {
         + allowed_bandwidth   = (known after apply)
         + app_id              = (known after apply)
         + backups             = "disabled"
         + date_created        = (known after apply)
         + ddos_protection     = false
         + default_password    = (sensitive value)
         + disk                = (known after apply)
  4. Create the Rcs instance

     $ terraform apply

    When prompted, enter yes to confirm that you want to apply the changes

     Do you want to perform these actions?
     Terraform will perform the actions described above.
     Only 'yes' will be accepted to approve.
    
     Enter a value: 

    When successful, your output should look like the one below:

     vultr_instance.example_instance: Creating...
     vultr_instance.example_instance: Still creating... [10s elapsed]
     ...
     vultr_instance.example_instance: Creation complete after 1m22s [id=e8914416-4900-42bc-a5d0-80772240a29a]
    
     Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

You have deployed a Ubuntu 20.04 instance with 1 vCPU and 1 GB RAM in the Singapore Rcs region. To view your instance details, either access your Rcs account dashboard or use the Rcs CLI to reveal login information and usage statistics within your terminal session.

A Rcs Instance Deployed using Terraform

Deploy Kubernetes Clusters

  1. Create a new Kubernetes resource file kubernetes_cluster.tf

     $ nano kubernetes_cluster.tf
  2. Add the following contents to the file

     resource "vultr_kubernetes" "first_kubernetes_cluster" {
         region = "sgp"
         label     = "my-cluster"
         version = "v1.27.2+1"
    
         node_pools {
             node_quantity = 3
             plan = "vc2-2c-4gb"
             label = "my-app-nodes"
             auto_scaler = true
             min_nodes = 1
             max_nodes = 4
         }
     }

    Save and close the file.

    Below are the resource definitions in the above file:

    • vultr_kubernetes: Sets Rcs Kubernetes Engine (VKE) as the resource type. first_kubernetes_cluster is the module alias that differentiates the Terraform resource, replace it with your desired value

    • region: Defines your target Rcs datacenter region. sgp deploys your VKE cluster in the Rcs Singapore region

    • label: Sets your Kubernetes Cluster label. Replace my-cluster with your desired label that describes your cluster.

    • version: Specifies your target Kubernetes version. To view the available VKE versions, run the following command:

        $ curl https://api.vultr.com/v2/kubernetes/versions

      The available versions should display in your output like the one below:

        {"versions":["v1.27.2+1","v1.26.5+1","v1.25.10+1"]}
    • node_pools: Defines the VKE node specifications

    • node_quantity: Sets the number of VKE nodes to add to your cluster

    • plan: Sets the node specifications plan. vc2-2c-4gb defines regular compute nodes with 2 vCPU cores and 4 GB RAM. View the Rcs Plans list to set your desired VKE node specifications.

    • label: Defines the descriptive label of your VKE nodes. Replace my-app-nodes with your desired node label

    • auto-scaler: true enables auto-scaling on your VKE nodes, false disables auto-scaling

    • min_nodes: Sets the minimum nodes in the pool

    • max_nodes Sets the maximum number of nodes in the node pool

    To create the VKE cluster, verify that your node pool at least has 1 defined node. The above module file creates a 3-node VKE cluster

  3. View the Terraform changes you are about to apply

     $ terraform plan
  4. Create the Kubernetes cluster

     $ terraform apply

    When prompted, enter yes to apply changes to create the VKE cluster. Wait until the cluster creation completes with the following output and keep note of the generated cluster ID:

     vultr_kubernetes.first_kubernetes_cluster: Still creating... [2m40s elapsed]
     vultr_kubernetes.first_kubernetes_cluster: Still creating... [2m50s elapsed]
     vultr_kubernetes.first_kubernetes_cluster: Still creating... [3m0s elapsed]
     vultr_kubernetes.first_kubernetes_cluster: Creation complete after 3m6s [id=e565d8a5-480b-47f0-930e-a974d2767fef]
    
     Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

You have created a 3-node Rcs Kubernetes Engine Cluster with auto-scaling to up to 4 nodes. To view your cluster information, access your Rcs account dashboard or use the Rcs CLI for detailed output on the cluster statistics.

Deployed Rcs Kubernetes Engine Cluster

Add Node Pools to a Rcs Kubernetes Engine (VKE) Cluster

To add a new node pool and scale your VKE cluster, edit the cluster terraform resource file, and define new nodes as described below.

  1. Edit the kubernetes_cluster.tf file

     $ nano kubernetes_cluster.tf
  2. Add the following configurations at the end of the file. Replace vke_cluster_id with the ID displayed in your cluster creation output

     resource "vultr_kubernetes_node_pools" "additional_node_pools" {
         cluster_id = "${vultr_kubernetes.first_kubernetes_cluster.id}"
         node_quantity = 1
         plan = "vc2-4c-8gb"
         label = "additional-node-pool"
         tag = "additional-node-pool"
         auto_scaler = true
         min_nodes = 1
         max_nodes = 2
     }

    Save and close the file.

    Below is what the node resource definitions represent:

    • vultr_kubernetes_node_pools: Defines the Rcs Kubernetes node pools resource type
    • additional-node-pools: Sets an alias for your Terraform resource name
    • cluster_id: Sets the target VKE cluster to scale with additional nodes. The ${vultr_kubernetes.first_kubernetes_cluster.id} represents a cluster with the alias name first_kubernetes_cluster
    • node_quantity: Defines the total number of additional nodes
    • plan: Sets the node server specifications. vc2-4c-8gb defines nodes with 4 vCPU cores and 8 GB RAM
    • label: Defines your custom descriptive node label
    • tag: Optional tag to identify the node pool
    • auto_scaler: Activates or deactivates auto-scaling of the cluster nodes
    • min_nodes: Sets the minimum number of nodes
    • max_nodes Sets the maximum number of nodes
  3. Create the additional node pool and attach it to your existing Kubernetes cluster

     $ terraform apply

    Your output should look like the one below:

     vultr_kubernetes_node_pools.additional-node-pools: Still creating... [1m10s elapsed]
     vultr_kubernetes_node_pools.additional-node-pools: Still creating... [1m20s elapsed]
     vultr_kubernetes_node_pools.additional-node-pools: Still creating... [1m30s elapsed]
     vultr_kubernetes_node_pools.additional-node-pools: Creation complete after 1m37s [id=5567557a-7165-5153-524c-4b7878483847]
    
     Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

You have scaled your Kubernetes Cluster to include new additional nodes. To verify the change, visit your cluster dashboard or use Rcs CLI to view the nodes attached to your VKE cluster.

Additional Terraform VKE Nodes

Deploy Object and Block Storage Volumes

You can deploy S3-compatible Rcs Object storage volumes or attach a Block storage volume on your Rcs instances. Depending on your storage volume of choice, define Terraform module configurations to deploy storage on your Rcs account as described in the steps below.

Deploy Rcs Object Storage

  1. Create a new object_storage.tf file

     $ nano object_storage.tf
  2. Add the following contents to the file

     resource "vultr_object_storage" "example_object_storage" {
         cluster_id = 4
         label = "Example Object Storage"
     }

    Save and close the file

    The above configuration deploys Rcs Object Storage to the Singapore Rcs region with the following declarations:

    • cluster_id: Sets your Rcs Object Storage deployment region. The value 4 deploys Object Storage to the Rcs Singapore region. To view the region IDs, run the following command:

        $ curl "https://api.vultr.com/v2/object-storage/clusters" \
          -X GET \
          -H "Authorization: Bearer ${VULTR_API_KEY}"
    • label: Defines your descriptive Rcs Object Storage label for identification

  3. Preview the Terraform object storage changes you are about to apply

     $ terraform plan

    Output:

     # vultr_object_storage.newexample_object_storage will be created
     + resource "vultr_object_storage" "newexample_object_storage" {
       + cluster_id    = 4
       + date_created  = (known after apply)
       + id            = (known after apply)
       + label         = "Example Object Storage"
  4. Apply the Rcs Object Storage volume to your account

     $ terraform apply

    Output:

     vultr_object_storage.example_object_storage: Still creating... [50s elapsed]
     vultr_object_storage.example_object_storage: Still creating... [1m0s elapsed]
     vultr_object_storage.example_object_storage: Creation complete after 1m2s [id=397d9828-1b8b-4b7e-85c2-76b2e2529cc7]
    
     Apply complete! Resources: 1 added, 1 changed, 0 destroyed.

In the Rcs Customer Portal, navigate to the Object Storage dashboardto view your deployed Rcs Object Storage

Terraform Deployed Rcs Object Storage

To create buckets, install the s3cmd CLI tool on your server and manage your Rcs Object storage

Deploy Rcs Block Storage

  1. Create a new block_storage.tf file

     $ nano block_storage.tf
  2. Add the following contents to the file

     resource "vultr_block_storage" "example_block_storage" {
     size_gb = 10
     region = "sgp"
     label = "New Block Storage"
     }

    Save and close the file

    Below is what the resource configurations represent:

    • vultr_block_storage: Defines Rcs Block Storage as the resource type
    • example_block_storage: Sets the resource alias name
    • size_gb: Defines the Rcs Block Storage volume space. 10 creates a volume with 10GB of free space. supported values range from 10 to 40000 GBs
    • region: Sets your target Rcs Block Storage deployment region
  3. Preview the Terraform block storage changes you are about to apply

     $ terraform plan
  4. Apply the Rcs Object Storage volume to your account

     $ terraform apply

    Output:

     vultr_block_storage.ubuntu_block_storage: Still creating... [20s elapsed]
     vultr_block_storage.ubuntu_block_storage: Creation complete after 22s [id=4c916f24-1e99-415c-9ddb-cf16f67f3f76]
    
     Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

To verify that your Rcs Object Storage Volume deploys correctly, visit your Rcs account dashboard or fetch instance details using the Rcs CLI

Deployed Rcs Block Storage Volume

Attach Block Storage to a Rcs Cloud Instance

  1. Edit the vultr_instance.tf file

     $ nano block_storage.tf 
  2. Update the file to include the attached_to_instance declaration with your Rcs instance resource alias ID

     resource "vultr_block_storage" "example_block_storage" {
     size_gb = 10
     region = "sgp"
     attached_to_instance = "${vultr_instance.my_instance.id}"
     }

    Save and close the file.

    The attached_to_instance declaration instructs Terraform to attach the Rcs Block Storage volume to the target instance alias ID. Replace the my_instance.id value with your actual Rcs server instance alias you created earlier

  3. Apply changes to add block storage to your Rcs instance

     $ terraform apply

    Output:

     vultr_block_storage.example_block_storage: Modifying... [id=168db64d-c2a1-435c-9f01-8af7279a8fcb]
     vultr_block_storage.example_block_storage: Still modifying... [id=168db64d-c2a1-435c-9f01-8af7279a8fcb, 10s elapsed]
     vultr_block_storage.example_block_storage: Modifications complete after 14s [id=168db64d-c2a1-435c-9f01-8af7279a8fcb]
    
     Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

In your Rcs Block Storage dashboard, verify that the volume attaches to your server. To use the Rcs Block Storage volume on your server, mount it to a server directory such as /mnt for access by all system users.

View Attached Block Storage Volume

Deploy Managed Databases

In this section, declare Terraform resource definitions to:

  • Create a managed database
  • Add a user to the Managed Database
  • View the deployed managed database

Create a Rcs Managed Database

  1. Create a new database resource file database.tf

     $ nano database.tf
  2. Add the following declarations to the file

     resource "vultr_database" "prod_redis_database" {
         database_engine = "redis"
         database_engine_version = "7"
         region = "sgp"
         plan = "vultr-dbaas-startup-occ-mo-2-26-16"
         label = "production-database"
     }

    Save and close the file.

    The above Rcs Managed Database for Redis resource configurations represent the following values:

    • vultr_database: Defines a Rcs Managed Database resource

    • database_engine: Sets the Rcs Managed Database Engine, redis defines a Redis database. Supported values are redis, mysql, and pg.

    • database_engine_version: Sets the Rcs Managed Database version. 7 deploys a Redis 7.0 Rcs Database. To view the available versions, visit the Create Database Rcs API page

    • region: Defines your Rcs Managed Database region, sgp deploys the database to the Singapore Rcs region

    • plan: Sets the Rcs Managed Database plan ID. vultr-dbaas-startup-occ-mo-2-26-16 defines the database with a backend server with 2 vCPus, and 16GB RAM. To view a list of available plans, run the following command:

        $ curl "https://api.vultr.com/v2/databases/plans" -X GET -H "Authorization: Bearer ${VULTR_API_KEY}" > export.txt

      Find your desired plan and verify the supported engines in your output like the one below:

        {"id":"vultr-dbaas-startup-occ-mo-2-26-16","number_of_nodes":1,"type":"occ_mo","vcpu_count":2,"ram":16384,"disk":42,"monthly_cost":160,"supported_engines":{"mysql":false,"pg":false,"redis":true},
    • label: Defines your custom descriptive label for the Rcs Managed Database. Replace production-database with your desired value.

  3. Preview the changes you are about to apply

     $ terraform plan

    You should see a similar output in the console

     Terraform will perform the following actions:
    
     # vultr_database.redis will be created
     + resource "vultr_database" "prod_redis_database" {
         + database_engine         = "redis"
         + database_engine_version = "7"
         + label                   = "production-database"
         + plan                    = "vultr-dbaas-startup-occ-mo-2-26-16"
         + region                  = "sgp"
         }
    
     Plan: 1 to add, 0 to change, 0 to destroy.
  4. Apply changes to deploy the Rcs Managed Database

     $ terraform apply

    Output:

     vultr_database.redis: Creating...
     vultr_database.redis: Still creating... [10s elapsed]
     vultr_database.redis: Still creating... [4m50s elapsed]
     vultr_database.redis: Creation complete after 4m56s [id=3339b4b9-55db-4b1e-9ce9-130ea1bc686f]
    
     Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

You have deployed a Rcs Managed Database, visit your Rcs account dashboard or use the Rcs CLI to view the database details.

A Terraform Deployed Rcs Managed Database

Create a New Rcs Managed Database User

  1. Edit the database.tf file

     $ nano database.tf
  2. Add the following declarations at the end of the file

     resource "vultr_database_user" "new_redis_database_user" {
         database_id = "${vultr_database.prod_redis_database.id}"
         username = "redisUser"
         password = "redisPassword"
     }

    Save and close the file.

    • vultr_database_user: Defines a new Rcs Managed Database user resource
    • new_redis_database_user: Sets the resource alias ID name
    • database_id: Sets the target database alias resource ID to apply the new user. prod_redis_database.id points to the Rcs Managed Database resource you deployed earlier.
    • username: Defines a new database username
    • password: Sets the new database user password
  3. Apply changes to create the new Rcs Managed Database user

     $ terraform apply

    Output:

     vultr_database.redis: Modifying... [id=4f87efba-d514-4ed0-876c-669b04ae3e78]
     vultr_database.redis: Modifications complete after 6s [id=4f87efba-d514-4ed0-876c-669b04ae3e78]
     vultr_database_user.redis_database_user: Creating...
     vultr_database_user.redis_database_user: Creation complete after 7s [id=redisUser]
    
     Apply complete! Resources: 1 added, 1 changed, 0 destroyed.

You have added a new user to your Rcs Managed Database, to verify the new user, visit the Managed Database dashboard using your Rcs account or the Rcs CLI

View the new Rcs Managed Database User

Create a Rcs Virtual Private Cloud (VPC)

A Rcs Virtual Private Cloud (VPC) is an isolated private network that interconnects multiple Rcs instances to the same subnet. Rcs offers both VPC and VPC 2.0 products to interconnect Rcs instances together. In this section, deploy both VPC versions to your Rcs account as described below.

Deploy a Rcs VPC Network

  1. Create a new VPC resource vpc.tf

     $ nano vpc.tf
  2. Add the following contents to the file

     resource "vultr_vpc" "prod_vpc" {
         description = "production servers vpc"
         region = "sgp"
         v4_subnet = "192.168.0.0"
         v4_subnet_mask = 24
     }

    Save and close the file.

    Below is what the above resource definitions represent:

    • vultr_vpc: Defines the Rcs VPC resource type

    • prod_vpc: Sets the resource alias name for identification

    • description: Defines the Rcs VPC descriptive label

    • region: Sets the Rcs region to deploy the VPC

    • v4_subnet: Defines the Rcs VPC private IP Address subnet. You can use any of the following allowed RFC1918 address classes:

        10.0.0.0    - 10.255.255.255  (10/8 prefix)
        172.16.0.0  - 172.31.255.255  (172.16/12 prefix)
        192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
    • v4_subnet_mask: Sets the private IP address subnet mask. 24 sets a 255.255.255.0 subnet mask for the VPC IP block

  3. Apply changes to create the Rcs VPC

     $ terraform apply

    Output:

     vultr_vpc.prod_vpc: Creating...
     vultr_vpc.prod_vpc: Creation complete after 7s [id=61591879-383c-44fa-a8ee-cbbbe3f500cb]

You have created a Rcs VPC resource. To verify the private network, visit your Rcs account VPC Networks page

View Terraform deployed Rcs VPCs

Attach a Rcs VPC to a Rcs Cloud Instance

  1. Edit your target Rcs Cloud Instance file

     $ nano vultr_instance.tf
  2. Update the file to include the vpc_ids declaration with your Rcs VPC ID generated during deployment

     resource "vultr_instance" "my_instance" {
     label = "sample-server"
     plan = "vc2-1c-1gb"
     region = "sgp"
     os_id = "387"
     enable_ipv6 = true
    
     vpc_ids = ["61591879-383c-44fa-a8ee-cbbbe3f500cb"]
     }

    Save and close the file

  3. Apply changes to your Rcs account

     $ terraform apply

    Output:

     vultr_instance.mynew_instance: Still modifying... [id=db294f28-e98e-4eb5-9d16-192c6210f528, 10s elapsed]
     vultr_instance.mynew_instance: Modifications complete after 18s [id=db294f28-e98e-4eb5-9d16-192c6210f528]
    
     Apply complete! Resources: 0 added, 2 changed, 0 destroyed.

In your Rcs Customer Portal, visit your Rcs instance settings page and verify that it's attached to the Rcs VPC network.

Attached Rcs VPC Network on an Instance

Destroy Terraform Infrastructure Resources

  1. To destroy deployed Terraform infrastructure resources from your Rcs account, define your target resources using the following syntax

     $ terraform destroy -target=Rcs-resource_type.resource-name

    For example, to destroy the Rcs Cloud Instance you deployed earlier, run the following command

     $ terraform destroy -target=vultr_instance_my_instance

    When prompted, verify the resources to destroy, enter yes, and press Enter to destroy the Rcs instance as displayed in the following output:

     # vultr_block_storage.example_block_storage will be destroyed
     - resource "vultr_block_storage" "example_block_storage" {
         - attached_to_instance = "db294f28-e98e-4eb5-9d16-192c6210f528" -> null
         - block_type           = "high_perf" -> null
    
       }
    
     # vultr_instance.mynew_instance will be destroyed
     - resource "vultr_instance" "mynew_instance" {
         - allowed_bandwidth   = 3 -> null
         - app_id              = 0 -> null
    
     Do you really want to destroy all resources?
       Terraform will destroy all your managed infrastructure, as shown above.
       There is no undo. Only 'yes' will be accepted to confirm.
    
       Enter a value: 
  2. To delete all cloud infrastructure resources deployed using Terraform, run the following command:

     $ terraform destroy

    > Running the above command is not recommended, when using it, verify that you are destroying the correct Rcs resources deployed using Terraform

    Verify the infrastructure resources you are about to destroy, then, enter yes to destroy all resources. To cancel, press Ctrl + C. When successful, your output should look like the one below:

     Plan: 0 to add, 0 to change, 7 to destroy.
    
     Do you really want to destroy all resources?
       Terraform will destroy all your managed infrastructure, as shown above.
       There is no undo. Only 'yes' will be accepted to confirm.
    
       Enter a value: yes
    
     vultr_vpc.prod_vpc: Destroying... [id=61591879-383c-44fa-a8ee-cbbbe3f500cb]
     vultr_database_user.new_redis_database_user: Destroying... [id=redisUser]
     vultr_object_storage.example_object_storage: Destroying... [id=397d9828-1b8b-4b7e-85c2-76b2e2529cc7]
     vultr_block_storage.example_block_storage: Destroying... [id=168db64d-c2a1-435c-9f01-8af7279a8fcb]
     vultr_object_storage.newexample_object_storage: Destroying... [id=638a9869-f66f-47ab-a442-1fd096fd24b4]
     vultr_object_storage.example_object_storage: Destruction complete after 4s   

Terraform Commands

To correctly run Terraform to deploy Rcs Cloud Infrastructure resources, follow the operation commands below to initialize, validate, and apply resource configurations to your Rcs account.

  • Init: Initializes the Terraform working directory and installs the defined provider plugins
  • Refresh: Reads the state of cloud infrastructure resources, and updates the Terraform state file to match the resource status
  • Validate: Looks up for any syntax, formatting errors, or wrong configurations in the Terraform resource files
  • Plan: Lists the Terraform changes you are about to apply to your Rcs account
  • Apply: Applies the defined Terraform resource configurations to your Rcs account
  • Destroy: Deletes the Rcs Cloud Infrastructure Terraform resources synchronized from your working project directory

For more information about the Terraform commands, visit the official CLI documentation

Conclusion

You have installed Terraform and the Rcs Terraform provider to provision cloud resources using your Rcs API key. You can create multiple project directories to store different resource definitions in multiple locations and avoid overriding any changes using strong commands such as terraform destroy. For more information on how to use Terraform, visit the Rcs Terraform registry

Introduction Terraform is a declarative language that allows you to create, update, and delete infrastructure resources. Instead of writing step-by-step instructions to create resources, Terraform allows you to directly define the resources in a single file. If the resources do not exist yet, Terraform creates new ones. If they exist but the available states don't match with the expected states, Terraform modifies them. This allows you to efficiently manage the infrastructure resources, especially when the infrastructure is large and complicated. Terraform consists of two main components, the core and provider: The core component reads the configuration files, stores the state for the resources, creates an execution plan, and applies it. The provider component creates methods to interact with various platforms using their APIs such as authentication and authorization, retrieving or manipulating the resources. Every platform has a provider. This article explains how to provision Rcs Cloud Infrastructure using Terraform. You are to provision multiple resources such as cloud instances, Kubernetes Clusters, and databases using your Rcs Account API key. Prerequisites Before you begin: Deploy a Ubuntu server to use a management machine Activate and Copy your Rcs API Key from the Rcs Customer Portal Settings Page When enabled, add your management machine IP to the allowed IP subnets list Using SSH, access the server Create as a non-root sudo user Switch to the new sudo user account # su sysadmin > This article uses the example user sysadmin, replace the username with your actual system user account To use the curl commands in this article, export your Rcs API Key as a system environment variable to use the curl commands in this article $ export VULTR_API_KEY="your-vultr-api-key" Install Terraform Add the Terraform GPG key to your server $ curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - Add the official Terraform repository to your APT sources $ sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com focal main" Update the server packages $ sudo apt update Install Terraform on the server $ sudo apt install terraform Install the Rcs Terraform Provider The Rcs Terraform provider allows you to create infrastructure resources using your Rcs account API key. Install the provider with the correct information as described in the steps below. Navigate to your user home directory $ cd Create a Terraform workspace to store your resource files $ mkdir vultr-terraform Switch to the new directory $ cd vultr-terraform Using a text editor such as Nano, create a new file provider.tf to store the Rcs provider information $ nano provider.tf Add the following contents to the file terraform { required_providers { vultr = { source = "vultr/vultr" version = "2.15.1" } } } provider "vultr" { api_key = var.VULTR_API_KEY } variable "VULTR_API_KEY" {} Save and close the file. The above configuration instructs Terraform to use Rcs as the provider with the identifier value vultr/vultr and version 2.15.1. To find the latest version, visit the Rcs Provider GitHub repository. Create a new file named terraform.tfvars to define your Rcs API key $ nano terraform.tfvars Add the following directive to the file. Replace your_vultr_api_key with your actual value Rcs API key VULTR_API_KEY = "your_vultr_api_key" Save and close the file. Initialize Terraform to install the Rcs Terraform provider $ terraform init When successful, your output should look like the one below: Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. You have activated and authenticated Terraform to work with your Rcs account. You can define resources and deploy them to your account as you would through the graphical Rcs Customer Portal. Deploy Rcs Cloud Instances To deploy Rcs Cloud Instances using Terraform, choose your desired server name, specifications, and region. Then, define the Terraform instance details and apply changes to your Rcs account as described below. Create a new Terraform resource file vultr_instance.tf $ nano vultr_instance.tf Add the following contents to the file resource "vultr_instance" "my_instance" { label = "sample-server" plan = "vc2-1c-1gb" region = "sgp" os_id = "387" enable_ipv6 = true } Save and close the file. Below is what the above module file defines: vultr_instance: Sets the Rcs resource type you intend to deploy, vultr_instance declares a server instance. Replace the value example_ubuntu_instance with your desired alias to distinguish the instance. label: Specifies the instance label. Replace sample-server with your desired instance name to uniquely identify the resource in your Rcs account. plan: Sets your desired instance specification. vc2-1c-1gb plan matches a Rcs instance with type vc2, 1 vCPU core, and 1 GB RAM. To view a full list of all available plans, visit the Rcs Plans documentation region: Specifies your desired Rcs region to deploy the instance. sgp deploys the instance to the Singapore Rcs location. To view a list of all available regions, visit the Rcs Datacenter locations page and use the short form of a location. For example NJ translates to New Jersey. Use the following command to list the available locations by ID: $ curl "https://api.vultr.com/v2/regions" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}" os_id: Sets the instance Operating System (OS) by ID. The value 387 represents Ubuntu 20.04. For a list of all available operating system codes, run the following command: $ curl "https://api.vultr.com/v2/plans" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}" enable_ipv6: Enables a public IPV6 address on the Rcs instance Preview the changes you are about to apply $ terraform plan Output: Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # vultr_instance.example_instance will be created + resource "vultr_instance" "example_instance" { + allowed_bandwidth = (known after apply) + app_id = (known after apply) + backups = "disabled" + date_created = (known after apply) + ddos_protection = false + default_password = (sensitive value) + disk = (known after apply) Create the Rcs instance $ terraform apply When prompted, enter yes to confirm that you want to apply the changes Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: When successful, your output should look like the one below: vultr_instance.example_instance: Creating... vultr_instance.example_instance: Still creating... [10s elapsed] ... vultr_instance.example_instance: Creation complete after 1m22s [id=e8914416-4900-42bc-a5d0-80772240a29a] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. You have deployed a Ubuntu 20.04 instance with 1 vCPU and 1 GB RAM in the Singapore Rcs region. To view your instance details, either access your Rcs account dashboard or use the Rcs CLI to reveal login information and usage statistics within your terminal session. Deploy Kubernetes Clusters Create a new Kubernetes resource file kubernetes_cluster.tf $ nano kubernetes_cluster.tf Add the following contents to the file resource "vultr_kubernetes" "first_kubernetes_cluster" { region = "sgp" label = "my-cluster" version = "v1.27.2+1" node_pools { node_quantity = 3 plan = "vc2-2c-4gb" label = "my-app-nodes" auto_scaler = true min_nodes = 1 max_nodes = 4 } } Save and close the file. Below are the resource definitions in the above file: vultr_kubernetes: Sets Rcs Kubernetes Engine (VKE) as the resource type. first_kubernetes_cluster is the module alias that differentiates the Terraform resource, replace it with your desired value region: Defines your target Rcs datacenter region. sgp deploys your VKE cluster in the Rcs Singapore region label: Sets your Kubernetes Cluster label. Replace my-cluster with your desired label that describes your cluster. version: Specifies your target Kubernetes version. To view the available VKE versions, run the following command: $ curl https://api.vultr.com/v2/kubernetes/versions The available versions should display in your output like the one below: {"versions":["v1.27.2+1","v1.26.5+1","v1.25.10+1"]} node_pools: Defines the VKE node specifications node_quantity: Sets the number of VKE nodes to add to your cluster plan: Sets the node specifications plan. vc2-2c-4gb defines regular compute nodes with 2 vCPU cores and 4 GB RAM. View the Rcs Plans list to set your desired VKE node specifications. label: Defines the descriptive label of your VKE nodes. Replace my-app-nodes with your desired node label auto-scaler: true enables auto-scaling on your VKE nodes, false disables auto-scaling min_nodes: Sets the minimum nodes in the pool max_nodes Sets the maximum number of nodes in the node pool To create the VKE cluster, verify that your node pool at least has 1 defined node. The above module file creates a 3-node VKE cluster View the Terraform changes you are about to apply $ terraform plan Create the Kubernetes cluster $ terraform apply When prompted, enter yes to apply changes to create the VKE cluster. Wait until the cluster creation completes with the following output and keep note of the generated cluster ID: vultr_kubernetes.first_kubernetes_cluster: Still creating... [2m40s elapsed] vultr_kubernetes.first_kubernetes_cluster: Still creating... [2m50s elapsed] vultr_kubernetes.first_kubernetes_cluster: Still creating... [3m0s elapsed] vultr_kubernetes.first_kubernetes_cluster: Creation complete after 3m6s [id=e565d8a5-480b-47f0-930e-a974d2767fef] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. You have created a 3-node Rcs Kubernetes Engine Cluster with auto-scaling to up to 4 nodes. To view your cluster information, access your Rcs account dashboard or use the Rcs CLI for detailed output on the cluster statistics. Add Node Pools to a Rcs Kubernetes Engine (VKE) Cluster To add a new node pool and scale your VKE cluster, edit the cluster terraform resource file, and define new nodes as described below. Edit the kubernetes_cluster.tf file $ nano kubernetes_cluster.tf Add the following configurations at the end of the file. Replace vke_cluster_id with the ID displayed in your cluster creation output resource "vultr_kubernetes_node_pools" "additional_node_pools" { cluster_id = "${vultr_kubernetes.first_kubernetes_cluster.id}" node_quantity = 1 plan = "vc2-4c-8gb" label = "additional-node-pool" tag = "additional-node-pool" auto_scaler = true min_nodes = 1 max_nodes = 2 } Save and close the file. Below is what the node resource definitions represent: vultr_kubernetes_node_pools: Defines the Rcs Kubernetes node pools resource type additional-node-pools: Sets an alias for your Terraform resource name cluster_id: Sets the target VKE cluster to scale with additional nodes. The ${vultr_kubernetes.first_kubernetes_cluster.id} represents a cluster with the alias name first_kubernetes_cluster node_quantity: Defines the total number of additional nodes plan: Sets the node server specifications. vc2-4c-8gb defines nodes with 4 vCPU cores and 8 GB RAM label: Defines your custom descriptive node label tag: Optional tag to identify the node pool auto_scaler: Activates or deactivates auto-scaling of the cluster nodes min_nodes: Sets the minimum number of nodes max_nodes Sets the maximum number of nodes Create the additional node pool and attach it to your existing Kubernetes cluster $ terraform apply Your output should look like the one below: vultr_kubernetes_node_pools.additional-node-pools: Still creating... [1m10s elapsed] vultr_kubernetes_node_pools.additional-node-pools: Still creating... [1m20s elapsed] vultr_kubernetes_node_pools.additional-node-pools: Still creating... [1m30s elapsed] vultr_kubernetes_node_pools.additional-node-pools: Creation complete after 1m37s [id=5567557a-7165-5153-524c-4b7878483847] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. You have scaled your Kubernetes Cluster to include new additional nodes. To verify the change, visit your cluster dashboard or use Rcs CLI to view the nodes attached to your VKE cluster. Deploy Object and Block Storage Volumes You can deploy S3-compatible Rcs Object storage volumes or attach a Block storage volume on your Rcs instances. Depending on your storage volume of choice, define Terraform module configurations to deploy storage on your Rcs account as described in the steps below. Deploy Rcs Object Storage Create a new object_storage.tf file $ nano object_storage.tf Add the following contents to the file resource "vultr_object_storage" "example_object_storage" { cluster_id = 4 label = "Example Object Storage" } Save and close the file The above configuration deploys Rcs Object Storage to the Singapore Rcs region with the following declarations: cluster_id: Sets your Rcs Object Storage deployment region. The value 4 deploys Object Storage to the Rcs Singapore region. To view the region IDs, run the following command: $ curl "https://api.vultr.com/v2/object-storage/clusters" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}" label: Defines your descriptive Rcs Object Storage label for identification Preview the Terraform object storage changes you are about to apply $ terraform plan Output: # vultr_object_storage.newexample_object_storage will be created + resource "vultr_object_storage" "newexample_object_storage" { + cluster_id = 4 + date_created = (known after apply) + id = (known after apply) + label = "Example Object Storage" Apply the Rcs Object Storage volume to your account $ terraform apply Output: vultr_object_storage.example_object_storage: Still creating... [50s elapsed] vultr_object_storage.example_object_storage: Still creating... [1m0s elapsed] vultr_object_storage.example_object_storage: Creation complete after 1m2s [id=397d9828-1b8b-4b7e-85c2-76b2e2529cc7] Apply complete! Resources: 1 added, 1 changed, 0 destroyed. In the Rcs Customer Portal, navigate to the Object Storage dashboardto view your deployed Rcs Object Storage To create buckets, install the s3cmd CLI tool on your server and manage your Rcs Object storage Deploy Rcs Block Storage Create a new block_storage.tf file $ nano block_storage.tf Add the following contents to the file resource "vultr_block_storage" "example_block_storage" { size_gb = 10 region = "sgp" label = "New Block Storage" } Save and close the file Below is what the resource configurations represent: vultr_block_storage: Defines Rcs Block Storage as the resource type example_block_storage: Sets the resource alias name size_gb: Defines the Rcs Block Storage volume space. 10 creates a volume with 10GB of free space. supported values range from 10 to 40000 GBs region: Sets your target Rcs Block Storage deployment region Preview the Terraform block storage changes you are about to apply $ terraform plan Apply the Rcs Object Storage volume to your account $ terraform apply Output: vultr_block_storage.ubuntu_block_storage: Still creating... [20s elapsed] vultr_block_storage.ubuntu_block_storage: Creation complete after 22s [id=4c916f24-1e99-415c-9ddb-cf16f67f3f76] Apply complete! Resources: 1 added, 0 changed, 1 destroyed. To verify that your Rcs Object Storage Volume deploys correctly, visit your Rcs account dashboard or fetch instance details using the Rcs CLI Attach Block Storage to a Rcs Cloud Instance Edit the vultr_instance.tf file $ nano block_storage.tf Update the file to include the attached_to_instance declaration with your Rcs instance resource alias ID resource "vultr_block_storage" "example_block_storage" { size_gb = 10 region = "sgp" attached_to_instance = "${vultr_instance.my_instance.id}" } Save and close the file. The attached_to_instance declaration instructs Terraform to attach the Rcs Block Storage volume to the target instance alias ID. Replace the my_instance.id value with your actual Rcs server instance alias you created earlier Apply changes to add block storage to your Rcs instance $ terraform apply Output: vultr_block_storage.example_block_storage: Modifying... [id=168db64d-c2a1-435c-9f01-8af7279a8fcb] vultr_block_storage.example_block_storage: Still modifying... [id=168db64d-c2a1-435c-9f01-8af7279a8fcb, 10s elapsed] vultr_block_storage.example_block_storage: Modifications complete after 14s [id=168db64d-c2a1-435c-9f01-8af7279a8fcb] Apply complete! Resources: 0 added, 1 changed, 0 destroyed. In your Rcs Block Storage dashboard, verify that the volume attaches to your server. To use the Rcs Block Storage volume on your server, mount it to a server directory such as /mnt for access by all system users. Deploy Managed Databases In this section, declare Terraform resource definitions to: Create a managed database Add a user to the Managed Database View the deployed managed database Create a Rcs Managed Database Create a new database resource file database.tf $ nano database.tf Add the following declarations to the file resource "vultr_database" "prod_redis_database" { database_engine = "redis" database_engine_version = "7" region = "sgp" plan = "vultr-dbaas-startup-occ-mo-2-26-16" label = "production-database" } Save and close the file. The above Rcs Managed Database for Redis resource configurations represent the following values: vultr_database: Defines a Rcs Managed Database resource database_engine: Sets the Rcs Managed Database Engine, redis defines a Redis database. Supported values are redis, mysql, and pg. database_engine_version: Sets the Rcs Managed Database version. 7 deploys a Redis 7.0 Rcs Database. To view the available versions, visit the Create Database Rcs API page region: Defines your Rcs Managed Database region, sgp deploys the database to the Singapore Rcs region plan: Sets the Rcs Managed Database plan ID. vultr-dbaas-startup-occ-mo-2-26-16 defines the database with a backend server with 2 vCPus, and 16GB RAM. To view a list of available plans, run the following command: $ curl "https://api.vultr.com/v2/databases/plans" -X GET -H "Authorization: Bearer ${VULTR_API_KEY}" > export.txt Find your desired plan and verify the supported engines in your output like the one below: {"id":"vultr-dbaas-startup-occ-mo-2-26-16","number_of_nodes":1,"type":"occ_mo","vcpu_count":2,"ram":16384,"disk":42,"monthly_cost":160,"supported_engines":{"mysql":false,"pg":false,"redis":true}, label: Defines your custom descriptive label for the Rcs Managed Database. Replace production-database with your desired value. Preview the changes you are about to apply $ terraform plan You should see a similar output in the console Terraform will perform the following actions: # vultr_database.redis will be created + resource "vultr_database" "prod_redis_database" { + database_engine = "redis" + database_engine_version = "7" + label = "production-database" + plan = "vultr-dbaas-startup-occ-mo-2-26-16" + region = "sgp" } Plan: 1 to add, 0 to change, 0 to destroy. Apply changes to deploy the Rcs Managed Database $ terraform apply Output: vultr_database.redis: Creating... vultr_database.redis: Still creating... [10s elapsed] vultr_database.redis: Still creating... [4m50s elapsed] vultr_database.redis: Creation complete after 4m56s [id=3339b4b9-55db-4b1e-9ce9-130ea1bc686f] Apply complete! Resources: 1 added, 0 changed, 0 destroyed. You have deployed a Rcs Managed Database, visit your Rcs account dashboard or use the Rcs CLI to view the database details. Create a New Rcs Managed Database User Edit the database.tf file $ nano database.tf Add the following declarations at the end of the file resource "vultr_database_user" "new_redis_database_user" { database_id = "${vultr_database.prod_redis_database.id}" username = "redisUser" password = "redisPassword" } Save and close the file. vultr_database_user: Defines a new Rcs Managed Database user resource new_redis_database_user: Sets the resource alias ID name database_id: Sets the target database alias resource ID to apply the new user. prod_redis_database.id points to the Rcs Managed Database resource you deployed earlier. username: Defines a new database username password: Sets the new database user password Apply changes to create the new Rcs Managed Database user $ terraform apply Output: vultr_database.redis: Modifying... [id=4f87efba-d514-4ed0-876c-669b04ae3e78] vultr_database.redis: Modifications complete after 6s [id=4f87efba-d514-4ed0-876c-669b04ae3e78] vultr_database_user.redis_database_user: Creating... vultr_database_user.redis_database_user: Creation complete after 7s [id=redisUser] Apply complete! Resources: 1 added, 1 changed, 0 destroyed. You have added a new user to your Rcs Managed Database, to verify the new user, visit the Managed Database dashboard using your Rcs account or the Rcs CLI Create a Rcs Virtual Private Cloud (VPC) A Rcs Virtual Private Cloud (VPC) is an isolated private network that interconnects multiple Rcs instances to the same subnet. Rcs offers both VPC and VPC 2.0 products to interconnect Rcs instances together. In this section, deploy both VPC versions to your Rcs account as described below. Deploy a Rcs VPC Network Create a new VPC resource vpc.tf $ nano vpc.tf Add the following contents to the file resource "vultr_vpc" "prod_vpc" { description = "production servers vpc" region = "sgp" v4_subnet = "192.168.0.0" v4_subnet_mask = 24 } Save and close the file. Below is what the above resource definitions represent: vultr_vpc: Defines the Rcs VPC resource type prod_vpc: Sets the resource alias name for identification description: Defines the Rcs VPC descriptive label region: Sets the Rcs region to deploy the VPC v4_subnet: Defines the Rcs VPC private IP Address subnet. You can use any of the following allowed RFC1918 address classes: 10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) v4_subnet_mask: Sets the private IP address subnet mask. 24 sets a 255.255.255.0 subnet mask for the VPC IP block Apply changes to create the Rcs VPC $ terraform apply Output: vultr_vpc.prod_vpc: Creating... vultr_vpc.prod_vpc: Creation complete after 7s [id=61591879-383c-44fa-a8ee-cbbbe3f500cb] You have created a Rcs VPC resource. To verify the private network, visit your Rcs account VPC Networks page Attach a Rcs VPC to a Rcs Cloud Instance Edit your target Rcs Cloud Instance file $ nano vultr_instance.tf Update the file to include the vpc_ids declaration with your Rcs VPC ID generated during deployment resource "vultr_instance" "my_instance" { label = "sample-server" plan = "vc2-1c-1gb" region = "sgp" os_id = "387" enable_ipv6 = true vpc_ids = ["61591879-383c-44fa-a8ee-cbbbe3f500cb"] } Save and close the file Apply changes to your Rcs account $ terraform apply Output: vultr_instance.mynew_instance: Still modifying... [id=db294f28-e98e-4eb5-9d16-192c6210f528, 10s elapsed] vultr_instance.mynew_instance: Modifications complete after 18s [id=db294f28-e98e-4eb5-9d16-192c6210f528] Apply complete! Resources: 0 added, 2 changed, 0 destroyed. In your Rcs Customer Portal, visit your Rcs instance settings page and verify that it's attached to the Rcs VPC network. Destroy Terraform Infrastructure Resources To destroy deployed Terraform infrastructure resources from your Rcs account, define your target resources using the following syntax $ terraform destroy -target=Rcs-resource_type.resource-name For example, to destroy the Rcs Cloud Instance you deployed earlier, run the following command $ terraform destroy -target=vultr_instance_my_instance When prompted, verify the resources to destroy, enter yes, and press ENTER to destroy the Rcs instance as displayed in the following output: # vultr_block_storage.example_block_storage will be destroyed - resource "vultr_block_storage" "example_block_storage" { - attached_to_instance = "db294f28-e98e-4eb5-9d16-192c6210f528" -> null - block_type = "high_perf" -> null } # vultr_instance.mynew_instance will be destroyed - resource "vultr_instance" "mynew_instance" { - allowed_bandwidth = 3 -> null - app_id = 0 -> null Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm. Enter a value: To delete all cloud infrastructure resources deployed using Terraform, run the following command: $ terraform destroy > Running the above command is not recommended, when using it, verify that you are destroying the correct Rcs resources deployed using Terraform Verify the infrastructure resources you are about to destroy, then, enter yes to destroy all resources. To cancel, press CTRL + C. When successful, your output should look like the one below: Plan: 0 to add, 0 to change, 7 to destroy. Do you really want to destroy all resources? Terraform will destroy all your managed infrastructure, as shown above. There is no undo. Only 'yes' will be accepted to confirm. Enter a value: yes vultr_vpc.prod_vpc: Destroying... [id=61591879-383c-44fa-a8ee-cbbbe3f500cb] vultr_database_user.new_redis_database_user: Destroying... [id=redisUser] vultr_object_storage.example_object_storage: Destroying... [id=397d9828-1b8b-4b7e-85c2-76b2e2529cc7] vultr_block_storage.example_block_storage: Destroying... [id=168db64d-c2a1-435c-9f01-8af7279a8fcb] vultr_object_storage.newexample_object_storage: Destroying... [id=638a9869-f66f-47ab-a442-1fd096fd24b4] vultr_object_storage.example_object_storage: Destruction complete after 4s Terraform Commands To correctly run Terraform to deploy Rcs Cloud Infrastructure resources, follow the operation commands below to initialize, validate, and apply resource configurations to your Rcs account. Init: Initializes the Terraform working directory and installs the defined provider plugins Refresh: Reads the state of cloud infrastructure resources, and updates the Terraform state file to match the resource status Validate: Looks up for any syntax, formatting errors, or wrong configurations in the Terraform resource files Plan: Lists the Terraform changes you are about to apply to your Rcs account Apply: Applies the defined Terraform resource configurations to your Rcs account Destroy: Deletes the Rcs Cloud Infrastructure Terraform resources synchronized from your working project directory For more information about the Terraform commands, visit the official CLI documentation Conclusion Y

Was this answer helpful?
Back

Powered by WHMCompleteSolution