Terraform Overview
Terraform is an infrastructure as code (IaC) tool developed by HashiCorp. It provides both the Community and Enterprise editions. Terraform uses HashiCorp Configuration Language (HCL) to declaratively describe the desired state of infrastructure and provides unified resource lifecycle management for multi-cloud, network, on-premises, and SaaS environments.
Basic Concepts
The core workflow of Terraform consists of three steps.
| Step | Description |
|---|---|
| Write | You can write human-readable configuration files to define the desired resource configurations for the infrastructure. Terraform uses declarative configuration files, so developers only need to describe the final state of required resources. |
| Plan | Terraform compares the target state described in the configuration files with the current state of the infrastructure and generates an execution plan that describes how to transition from the current state to the desired state. The execution plan is presented as an infrastructure manifest. |
| Apply | After the execution plan is confirmed, Terraform executes the recommended actions in the correct sequence, with resource dependencies considered, and creates resources in the dependency sequence. |
The following table describes the main components of Terraform.
| Component | Description |
|---|---|
| Configuration files | The core carrier for developers to define infrastructure resources. It is used to declare the required provider, resources, and their configuration parameters. |
| Modules | A reusable infrastructure code unit that encapsulates complex architectures into modular templates to avoid repeated coding |
| State files | Files that record the current state of the infrastructure, including the relationships between components, configurations, and resources |
| Providers | Plugins for Terraform to interact with the APIs of external services and platforms, allowing Terraform to manage resources in the environment |
| Terraform CLI | Terraform's command-line tool, which is used to initialize the working directories, generate execution plans, apply changes, and interact with core components |
Advantages of Terraform
- Multi-cloud management
Terraform is suitable for multi-cloud solutions. O&M personnel can use Terraform to centrally manage resources on multiple clouds, including Huawei Cloud.
- Automatic infrastructure management
Terraform can create templates for configuration files, enabling automatic and rapid resource creation without the need for interaction.
- High reusability and modularization
Common architecture configurations can be compiled into reusable modules for quick and standardized replication.
- Lower development costs
You can create development and deployment environments on demand to reduce costs.
Using Terraform to Manage CCE Resources
Terraform can use the following two types of resources to manage CCE clusters and related resources: CPU resource type.
- Resources: newly created resources
- Data source: used to query existing resources and obtain their attributes
Resource List
| Name | Purpose |
|---|---|
| huaweicloud_cce_access_policy | Grants RBAC permissions to a CCE cluster. |
| huaweicloud_cce_addon | Deploys add-ons in a CCE cluster. |
| huaweicloud_cce_chart | Manages the charts of a CCE cluster. |
| huaweicloud_cce_cluster | Creates a CCE cluster. |
| huaweicloud_cce_cluster_certificate_revoke | Deletes the granted RBAC permissions. |
| huaweicloud_cce_cluster_log_config | Manages the log configuration of a CCE cluster. |
| huaweicloud_cce_cluster_pod_identity_association | Creates a pod identity association. |
| huaweicloud_cce_cluster_upgrade | Upgrades a CCE cluster. |
| huaweicloud_cce_image_cache | Creates a container image cache. |
| huaweicloud_cce_namespace | Creates a namespace in a CCE cluster. |
| huaweicloud_cce_node | Creates a node in a CCE cluster. |
| huaweicloud_cce_node_attach | Adds an ECS to a CCE cluster for management. |
| huaweicloud_cce_node_pool | Creates a node pool in a CCE cluster. |
| huaweicloud_cce_node_pool_nodes_add | Adds a node in a CCE cluster to a specified node pool. |
| huaweicloud_cce_node_pool_scale | Scales a node pool in a CCE cluster. |
| huaweicloud_cce_node_sync | Synchronizes cloud server information to a CCE node. |
| huaweicloud_cce_nodes_certificate_rotatecredentials | Rotates a user's cluster certificate. |
| huaweicloud_cce_nodes_remove | Deletes a CCE node. |
| huaweicloud_cce_partition | Creates a CCE node partition. |
| huaweicloud_cce_pvc | Creates a PVC in a CCE cluster. |
| huaweicloud_cce_release | Deploys an application template in a CCE cluster. |
Data Source List
| Name | Purpose |
|---|---|
| huaweicloud_cce_access_policies | Obtains the existing RBAC permissions of a CCE cluster. |
| huaweicloud_cce_addon_template | Obtains the add-on configuration template of a CCE cluster. |
| huaweicloud_cce_addons | Obtains the add-on deployment information in a CCE cluster. |
| huaweicloud_cce_chart_values | Obtains the values of a chart. |
| huaweicloud_cce_charts | Obtains the chart list of a CCE cluster. |
| huaweicloud_cce_cluster | Obtains information about a CCE cluster. |
| huaweicloud_cce_cluster_certificate | Obtains the authentication credential of a CCE cluster. |
| huaweicloud_cce_cluster_configuration_details | Obtains the configuration details of a CCE cluster. |
| huaweicloud_cce_cluster_configurations | Obtains the existing configuration of a CCE cluster. |
| huaweicloud_cce_cluster_pod_identity_assume_agency | Obtains pod identity association information of a CCE cluster. |
| huaweicloud_cce_cluster_upgrade_info | Obtains the upgrade information of a CCE cluster. |
| huaweicloud_cce_clusters | Obtains the list of existing CCE clusters. |
| huaweicloud_cce_flavor_specifications | Obtains available CCE cluster specifications. |
| huaweicloud_cce_image_caches | Obtains the image cache list. |
| huaweicloud_cce_node | Obtains the node information of a CCE cluster. |
| huaweicloud_cce_node_pool | Obtains the node pool information of a CCE cluster. |
| huaweicloud_cce_node_pools | Obtains the node pool list of a CCE cluster. |
| huaweicloud_cce_nodes | Obtains the node list of a CCE cluster. |
| huaweicloud_cce_releases | Obtains the charts that have been deployed in a CCE cluster. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot