Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Creating a Stack

Updated on 2024-07-11 GMT+08:00

On the Stacks page, click Create Stack in the upper right corner, as shown in Figure 1.

Figure 1 Creating a stack

Procedure:

  1. Select a template.
    There are two ways to select a template, as shown in Figure 2: (1) Enter a URL of an OBS template. (2) Upload a local template file. (3) Select a template from My Templates.
    Figure 2 Selecting a template

    You can upload template files in either .tf or .tf.json format.

    Sample of the .tf template for creating a VPC and an ECS:

    terraform {
        required_providers {
          huaweicloud = {
            source  = "huawei.com/provider/huaweicloud"
            version = "1.41.0"
          }
        }
      }
    
      provider "huaweicloud" {
        cloud     = "myhuaweicloud.com"
        endpoints = {
          iam = "iam.cn-north-4.myhuaweicloud.com"
        }
        insecure   = true
        region     = "cn-north-4"
        auth_url   = "https://iam.cn-north-4.myhuaweicloud.com:31943/v3"
      }
    
      variable "vpc_name" {
        type        = string
        description = "vpc name"
        default     = "rf_teststack_vpc"
        sensitive   = true
        nullable    = false
      }
    
      variable "subnet_name" {
        type        = string
        description = "subnet name"
        default     = "rf_teststack_subnet"
      }
    
      variable "ecs_name" {
        type        = string
        description = "ecs name"
        default     = "rf_teststack_ecs"
      }
    
      variable "ecs_admin_passwd" {
        type        = string
        description = "ecs passwd"
      }
    
      resource "huaweicloud_vpc" "rf_doc_vpc" {
        name   = var.vpc_name
        cidr   = "192.168.0.0/16"
      }
    
      resource "huaweicloud_vpc_subnet" "rf_doc_subnet" {
        name       = var.subnet_name
        vpc_id     = huaweicloud_vpc.rf_doc_vpc.id
        cidr       = "192.168.1.0/24"
        gateway_ip = "192.168.1.1"
      }
    
      resource "huaweicloud_compute_instance" "rf_doc_ecs" {
        name               = var.ecs_name
        flavor_id          = "c7.large.2"
        admin_pass         = var.ecs_admin_passwd
        image_id           = "cecc4bcf-b055-4d35-bd5f-693d4412eaef"
        network {
          uuid = huaweicloud_vpc_subnet.rf_doc_subnet.id
        }
        system_disk_type   = "SAS"
        system_disk_size   = 100
        stop_before_destroy = false
        delete_disks_on_termination = true
        charging_mode      = "postPaid"
        auto_renew         = false
      }
    
      output "ecs_address" {
        value = huaweicloud_compute_instance.rf_doc_ecs.access_ip_v4
        description = "The ecs private address."
      }
    
      output "ecs_id" {
        value = huaweicloud_compute_instance.rf_doc_ecs.id
        description = "The ecs resource id."
      }

    Sample of the .tf.json template for creating a VPC and an ECS:

    {
        "terraform": {
          "required_providers": {
            "huaweicloud": {
              "source": "huawei.com/provider/huaweicloud",
              "version": "1.41.0"
            }
          }
        },
        "provider": {
          "huaweicloud": {
            "cloud": "myhuaweicloud.com",
            "endpoints": {
              "iam":"iam.cn-north-4.myhuaweicloud.com"
            },
            "insecure": true,
            "region": "cn-north-4",
            "auth_url": "https://iam.cn-north-4.myhuaweicloud.com:31943/v3"
          }
        },
        "variable": {
          "vpc_name": {
            "type": "string",
            "description": "vpc name",
            "default": "rf_teststack_vpc",
            "sensitive": true,
            "nullable": false
          },
          "subnet_name": {
            "type": "string",
            "description": "subnet name",
            "default": "rf_teststack_subnet"
          },
          "ecs_name": {
            "type": "string",
            "description": "ecs name",
            "default": "rf_teststack_ecs"
          },
          "ecs_admin_passwd": {
            "type": "string",
            "description": "ecs passwd"
          }
        },
        "resource": {
          "huaweicloud_vpc": {
            "rf_doc_vpc": {
              "name": "${var.vpc_name}",
              "cidr": "192.168.0.0/16"
            }
          },
          "huaweicloud_vpc_subnet": {
            "rf_doc_subnet": {
              "name": "${var.subnet_name}",
              "vpc_id": "${huaweicloud_vpc.rf_doc_vpc.id}",
              "cidr": "192.168.1.0/24",
              "gateway_ip": "192.168.1.1"
            }
          },
          "huaweicloud_compute_instance": {
            "rf_doc_ecs": {
              "name": "${var.ecs_name}",
              "flavor_id": "c7.large.2",
              "admin_pass": "${var.ecs_admin_passwd}",
              "image_id": "cecc4bcf-b055-4d35-bd5f-693d4412eaef",
              "network": {
                "uuid": "${huaweicloud_vpc_subnet.rf_doc_subnet.id}"
              },
              "system_disk_type": "SAS",
              "system_disk_size": 100,
              "stop_before_destroy": false,
              "delete_disks_on_termination": true,
              "charging_mode": "postPaid",
              "auto_renew": false
            }
          }
        },
        "output": {
          "ecs_address": {
            "value": "${huaweicloud_compute_instance.rf_doc_ecs.access_ip_v4}",
            "description": "The ecs private address."
          },
          "ecs_id": {
            "value": "${huaweicloud_compute_instance.rf_doc_ecs.id}",
            "description": "The ecs resource id."
          }
        }
      }

    CAUTION:

    The sample template contains charged resources. Check whether resources need to be enabled before using the template.

    This template consists of five parts:

    1. huaweicloud_vpc in resource indicates VPC information.
    2. huaweicloud_vpc_subnet in resource indicates information about a subnet defined in the VPC. A subnet is a segment within the IP address range of the VPC.
    3. huaweicloud_compute_instance in resource indicates information about an ECS defined in the template.
    4. variable indicates variables defined by users in templates during stack creation and deployment.
    5. output defines the outputs of templates. After a stack is created, its output is generated based on the definition and displayed on the Outputs tab page.
  2. Configure parameters.

    Click Next to go to the Configure Parameters page, where you can modify the stack name and description, as shown in Figure 3.

    CAUTION:

    The stack name must start with a letter and can contain a maximum of 128 characters, including letters, digits, underscores (_), and hyphens (-). The name must be unique.

    A stack description can contain a maximum of 1,024 characters.

    Figure 3 Configuring parameters

    Parameters marked with a red asterisk (*) are mandatory. Set these parameters to valid values.

    If you enter an invalid value, the text box will turn red (as shown in Figure 4) and clicking Next will not redirect you to the next page.

    Figure 4 Text box with an invalid value

    Click Next. The Configure Stack page is displayed.

    CAUTION:

    If the stack name or description is imported using a URL and contains special characters, the characters must be encoded following the HTTP encoding rules first.

    Check whether the default VPC, subnet, and ECS names used on this page already exist on the corresponding consoles. If the names already exist, change them to unique ones to prevent creation failures.

  3. Configure the stack.
    Click Next to go to the Advanced Settings page, as shown in Figure 5.
    Figure 5 Configuring the stack

    Mandatory parameter (marked with *)

    Agency: An agency can clearly define operation permissions of RFS (such as creation, update, and deletion) on stack resources. If the agency permissions are insufficient, subsequent operations may fail.

    Optional parameters:

    Deletion Protection: prevents the stack from being deleted accidentally. After a stack is created, you can update this configuration by clicking Update in the Operation column.

    Auto-Rollback: Enabling auto-rollback will revert the stack to the last successful resource status in the event of a failed operation.

    Click Next to go to the Confirm Configurations page.

  4. Confirm the configurations.

    After you confirm the configurations, you can click either Create Execution Plan or Directly Deploy Stack.

    1. If you click Directly Deploy Stack, a confirmation dialog box will be displayed.
      Figure 6 Directly deploy stack
      Click Yes. A new stack is generated and its status is Deployment In Progress, as shown in Figure 7.
      Figure 7 Deployment in progress

      Then, the status changes to Deployment Complete, as shown in Figure 8.

      Figure 8 Deployment complete
    2. Clicking Create Execution Plan will open a dialog box where you can name and describe the execution plan, as shown in Figure 9.
      Figure 9 Create Execution Plan dialog box

      Click OK. The Execution Plans tab page is displayed.

      Wait until the execution plan is created and refresh the page. The execution plan status changes to Available, as shown in Figure 10.

      Figure 10 Available

      Return to the stack list page. The stack status is Creation Complete, as shown in Figure 11.
      Figure 11 Stack list

      CAUTION:

      Creating an execution plan can preview the resource attribute changes of the entire stack and evaluate the impact. If the execution plan meets your expectations, you can apply the plan. Creating an execution plan does not incur fees. The system changes your stack only when you execute the plan.

      Click Deploy in the Operation column of the execution plan to deploy it, as shown in Figure 12.

      Figure 12 Execution plan dialog box

      In the Execution Plan dialog box, click Execute. A message is displayed in the upper right corner, indicating that the execution plan is being deployed. Return to the stack list page. A new stack is generated and its status is Deployment In Progress, as shown in Figure 13.

      Figure 13 Deployment in progress

      Then, the stack status changes to Deployment Complete, as shown in Figure 14.

      Figure 14 Deployment complete

      On the Execution Plans tab page of the stack details page, the execution plan status is Applied, as shown in Figure 15.

      Figure 15 Applied

      Click the Events tab. The event list shows that resources of the stack are deployed, as shown in Figure 16.

      Figure 16 Resources deployed

      You can view details on the console of the corresponding cloud service.

      1. In the service list, locate and click Elastic Cloud Server. On the displayed page, view the deployed ECS, as shown in Figure 17.
        Figure 17 ECS

        Resources of the stack are deployed.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback