Huawei Cloud using Terraform

Introduction:

What is Huawei Cloud?

Huawei Cloud is a cloud computing service provided by Huawei Technologies Co., Ltd., a Chinese multinational technology company. It offers a wide range of cloud-based services and solutions to businesses, governments, and other organizations globally. 

Huawei Cloud is designed to help organizations of all sizes leverage cloud technology to enhance their IT infrastructure, improve business agility, and reduce operational costs. It competes with other major cloud service providers like Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). 

Why Huawei Cloud? 

Huawei Cloud can offer several benefits, making it an attractive option for businesses and organizations looking to leverage cloud computing. Here are some reasons why one might consider using Huawei Cloud: 

  • Cost-Effective Solutions: Huawei Cloud often provides competitive pricing, making it an affordable choice for businesses of various sizes, especially in regions where Huawei has a strong presence. 
  • Strong in Emerging Markets: Huawei Cloud has a robust presence in emerging markets, providing localized services and support. This can be advantageous for businesses operating or expanding in these regions. 
  • Comprehensive Product and Service Portfolio: Huawei Cloud offers a wide range of services, including IaaS, PaaS, SaaS, AI, and big data solutions. This comprehensive portfolio allows businesses to find solutions tailored to their specific needs. 
  • Advanced AI and Big Data Capabilities: Huawei Cloud’s AI and big data services are advanced, providing tools for machine learning, data analytics, and more. These services help organizations gain insights, optimize operations, and drive innovation. 
  • Customer Support and Service: Huawei Cloud offers robust customer support, including technical assistance, training, and resources to help businesses maximize their use of cloud services. 

This blog explains how to create an ECS VM in Huawei Cloud. For this blog, I am creating an EulerOS 2.5 x86 instance. 
 
To create an instance in Huawei Cloud you need to have the below credentials of the respective Huawei Cloud account 
1. Username 
2. Access Key 
3. Secret Key 

These details can be fetched from the Huawei Cloud console in the respective account. 

Steps to create the instance:

  1. Create a file provider.tf  

2. Create a variables.tf file 

3. We need to have some outputs after the instance is created. For this create a new file outputs.tf 

4. We need to get some data from the Huawei cloud to create the resource. For this create a new file data.tf and add all required data scripts in this file 

5. Now we have all basic pre-reqs ready to create the instance. So, let’s create the instance now. For this create a new file main.tf 

After having all these files created, now it’s time to run the scripts. To do this run

Once terraform is initialized successfully, run 

All scripts here have been separated into different files for better understanding and to achieve a clean and clear look of the code. 

Conclusion:

Creating an ECS instance on Huawei Cloud using Terraform involves a series of well-defined steps that leverage Huawei Cloud’s robust and cost-effective cloud computing services. By following this guide, users can set up their instances efficiently while taking advantage of Huawei Cloud’s advanced AI and big data capabilities, comprehensive service portfolio, and strong presence in emerging markets. 

The process begins with setting up the necessary credentials and defining provider configurations in provider.tf. Variables for the instance’s attributes are specified in variables.tf, while outputs.tf and data.tf handle the retrieval and output of essential data. Finally, the main resources are created and configured in main.tf, which includes setting up the ECS instance and binding it to an Elastic IP. Running terraform init and terraform apply commands completes the instance creation, deploying a ready-to-use ECS VM. 

By separating the Terraform scripts into different files, this approach ensures a clean, organized, and modular infrastructure setup, making it easier to manage and understand. This method not only simplifies the deployment process but also enhances scalability and maintainability for future cloud infrastructure projects. 

tarique-salat

Associate QA Manager