全部產品
Search
文件中心

Cloud Firewall:調整互連網防火牆存取控制策略優先順序

更新時間:Jun 30, 2024

本文介紹如何使用Terraform調整互連網防火牆存取控制策略優先順序。

前提條件

  • 已建立阿里雲帳號和存取金鑰(AccessKey)。具體操作,請參見建立AccessKey

  • 已經安裝並配置了Terraform。

注意事項

調整互連網存取控制策略優先順序

  1. 在Terraform執行目錄下的terraform.tf檔案中,配置如下內容。

    程式碼範例如下:

    provider "alicloud" {
      version = "~> 1.203.0"
    }
    
    resource "alicloud_cloud_firewall_control_policy_order" "example" {
      acl_uuid  = "1b5f9953-0a00-46d6-8282-0cf08ff5****"
      direction = "out"
      order     = 1
    }

  1. 運行terraform init,對環境進行初始化。

    程式碼範例如下:

    Initializing the backend...
    
    Initializing provider plugins...
    - Checking for available provider plugins...
    - Downloading plugin for provider "alicloud" (hashicorp/alicloud) 1.203.0...
    
    
    Warning: registry.terraform.io: For users on Terraform 0.13 or greater, this provider has moved to aliyun/alicloud. Please update your source in required_providers.
    
    
    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.
    
    If you ever set or change modules or backend configuration for Terraform,
    rerun this command to reinitialize your working directory. If you forget, other
    commands will detect it and remind you to do so if necessary.

  1. 運行terraform apply出現如下配置資訊後,確認配置資訊並輸入yes,開始建立。

    程式碼範例如下,修改成功後,可以返回存取控制策略ID為1b5f9953-0a00-46d6-8282-0cf08ff5****,方向為出方向(out)。

    An execution plan has been generated and is shown below.
    Resource actions are indicated with the following symbols:
      + create
    
    Terraform will perform the following actions:
    
      # alicloud_cloud_firewall_control_policy_order.example will be created
      + resource "alicloud_cloud_firewall_control_policy_order" "example" {
          + acl_uuid  = "1b5f9953-0a00-46d6-8282-0cf08ff5****"
          + direction = "out"
          + id        = (known after apply)
          + order     = 1
        }
    
    Plan: 1 to add, 0 to change, 0 to destroy.
    
    Do you want to perform these actions?
      Terraform will perform the actions described above.
      Only 'yes' will be accepted to approve.
    
      Enter a value: yes
    
    alicloud_cloud_firewall_control_policy_order.example: Creating...
    alicloud_cloud_firewall_control_policy_order.example: Creation complete after 1s [id=1b5f9953-0a00-46d6-8282-0cf08ff5****:out]

  2. 查看結果。

    • 運行terraform show查看存取控制策略的優先順序。

      # alicloud_cloud_firewall_control_policy_order.example:
      resource "alicloud_cloud_firewall_control_policy_order" "example" {
          acl_uuid  = "1b5f9953-0a00-46d6-8282-0cf08ff5****"
          direction = "out"
          id        = "1b5f9953-0a00-46d6-8282-0cf08ff5****:out"
          order     = 1
      }
    • 登入Cloud Firewall控制台,在存取控制>互連網邊界頁面搜尋策略ID查看存取控制策略的優先順序。