全部產品
Search
文件中心

Cloud Firewall:添加Cloud Firewall成員帳號

更新時間:Jun 30, 2024

本文介紹如何使用Terraform添加Cloud Firewall成員帳號。

注意事項

前提條件

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

  • 已經安裝並配置了Terraform。

添加Cloud Firewall成員帳號

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

    程式碼範例如下:

    provider "alicloud" {
      version = "~> 1.203.0"
    }
    
    resource "alicloud_cloud_firewall_instance_member" "default" {
      member_desc = "Added memberUid by Terraform"
      member_uid  = 180998553943****
    }

  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,開始建立。

    程式碼範例如下:

    Terraform will perform the following actions:
    
      # alicloud_cloud_firewall_instance_member.default will be created
      + resource "alicloud_cloud_firewall_instance_member" "default" {
          + create_time         = (known after apply)
          + id                  = (known after apply)
          + member_desc         = "Added memberUid by Terraform"
          + member_display_name = (known after apply)
          + member_uid          = "180998553943****"
          + modify_time         = (known after apply)
          + status              = (known after apply)
        }
    
    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_instance_member.default: Creating...
    alicloud_cloud_firewall_instance_member.default: Creation complete after 9s [id=180998553943****]
    
    Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

    建立成功後,可以返回成員帳號ID為180998553943****。

  2. 查看結果。

    • 運行terraform show查看Cloud Firewall成員帳號詳細資料。

      # alicloud_cloud_firewall_instance_member.default:
      resource "alicloud_cloud_firewall_instance_member" "default" {
          create_time         = 1681899524
          id                  = "180998553943****"
          member_desc         = "Added memberUid by Terraform"
          member_display_name = "beaver_qa3"
          member_uid          = "180998553943****"
          modify_time         = 1681899524
          status              = "normal"
      }
    • 登入Cloud Firewall控制台,在系統設定>帳號統一管理頁面,查看Cloud Firewall成員帳號詳細資料。