调整互联网防火墙访问控制策略优先级

本文介绍如何使用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
      }
    • 登录云防火墙控制台,在访问控制>互联网边界页面搜索策略ID查看访问控制策略的优先级。

      image