หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

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
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

Configuring the Network

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

Application Scenario

Before creating your VPCs, determine how many VPCs, the number of subnets, and what IP address ranges or connectivity options you will need. For details about network planning, see VPC Best Practices.

In this topic, you will create a VPC to host web applications or websites. This VPC uses the private CIDR block 192.168.0.0/16 and is divided into three subnets for web, application, and database servers. In addition, servers are arranged into different security groups with targeted access control rules configured.

Procedure

  1. Create a VPC and three subnets.

    1. Create the network.tf file, enter the following information, and save the file:
      resource "huaweicloud_vpc" "vpc" {
        name = "vpc-web"
        cidr = "192.168.0.0/16"
      }
      resource "huaweicloud_vpc_subnet" "subnet1" {
        name       = "subnet-web"
        cidr       = "192.168.10.0/24"
        gateway_ip = "192.168.10.1"
        vpc_id     = huaweicloud_vpc.vpc.id
        dns_list   = ["100.125.1.250", "100.125.129.250"]
      }
      resource "huaweicloud_vpc_subnet" "subnet2" {
        name       = "subnet-app"
        cidr       = "192.168.20.0/24"
        gateway_ip = "192.168.20.1"
        vpc_id     = huaweicloud_vpc.vpc.id
        dns_list   = ["100.125.1.250", "100.125.129.250"]
      }
      resource "huaweicloud_vpc_subnet" "subnet3" {
        name       = "subnet-db"
        cidr       = "192.168.30.0/24"
        gateway_ip = "192.168.30.1"
        vpc_id     = huaweicloud_vpc.vpc.id
        dns_list   = ["100.125.1.250", "100.125.129.250"]
      }
      Table 1 Parameter description

      Resource Name

      Parameter

      Description

      huaweicloud_vpc

      name

      VPC name.

      • Value: a string of 1 to 64 characters that can contain letters, digits, underscores (_), hyphens (-), and periods (.)
      • Constraints: A VPC name must be unique under a tenant.

      cidr

      Available subnets in the VPC. The value must be in CIDR format, for example, 192.168.0.0/16.

      huaweicloud_vpc_subnet

      name

      Subnet name.

      • Value: a string of 1 to 64 characters that can contain letters, digits, underscores (_), hyphens (-), and periods (.)

      cidr

      CIDR block of the subnet.

      • Value: a CIDR block in the range allowed in the VPC
      • Constraints: The value must be in CIDR format. The subnet mask length cannot be greater than 28 bits.

      gateway_ip

      Subnet gateway address.

      vpc_id

      ID of the VPC to which the subnet belongs. The value is referenced from huaweicloud_vpc.vpc.id.

      dns_list

      Addresses of DNS servers on the subnet. If this parameter is not specified, the value is left blank by default. For details about private DNS server addresses, see What Are the Private DNS Server Addresses Provided by the DNS Service?

    2. Run terraform init to initialize the environment.
    3. Run terraform plan to view resources.
    4. After you confirm that the resource information is correct, run terraform apply to start VPC and subnet creation.
    5. Run terraform show to view the created VPC and subnets.

  2. Create a security group and add a rule to it.

    1. Add the following information to the network.tf file:
      resource "huaweicloud_networking_secgroup" "mysecgroup" {
        name                 = "secgroup"
        description          = "My security group"
        delete_default_rules = true
      }
      resource "huaweicloud_networking_secgroup_rule" "secgroup_rule" {
        direction         = "ingress"
        ethertype         = "IPv4"
        protocol          = "tcp"
        port_range_min    = 22
        port_range_max    = 22
        remote_ip_prefix  = "0.0.0.0/0"
        security_group_id = huaweicloud_networking_secgroup.mysecgroup.id
      }
    2. Run terraform plan to view resources.
    3. After you confirm that the resource information is correct, run terraform apply to start security group and rule creation.
    4. Run terraform show to view the created security group and rule.

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback