すべてのプロダクト
Search
ドキュメントセンター

Cloud Firewall:Cloud Firewallの有効化

最終更新日:Aug 14, 2024

このトピックでは、Terraformを使用してCloud Firewallをアクティブ化する方法について説明します。

使用上の注意

  • Terraformランタイム環境: Alibaba Cloud Shell

  • Terraformバージョン: 0.12

  • alicloudバージョン: 1.203.0

  • リソース定義: cloud_firewall_instance

前提条件

  • Alibaba CloudアカウントとAccessKeyペアが作成されます。 詳細については、「AccessKey の作成」をご参照ください。

  • Terraformがインストールされ、設定されます。

手順

  1. Terraformの実行ディレクトリで、terraform.tfファイルを設定します。

    以下にコードの例を示します。

    provider "alicloud" {
      version = "~> 1.203.0"
    }
    
    resource "alicloud_cloud_firewall_instance" "example" {
      payment_type    = "Subscription"
      spec            = "premium_version"
      ip_number       = 20
      band_width      = 10
      cfw_log         = false
      cfw_log_storage = 1000
      cfw_service     = false
      period          = 6
    }

  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コマンドを実行します。 次の情報が表示されたら、情報を確認し、はいと入力してクラウドファイアウォールを有効にします。

    以下にコードの例を示します。

    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_instance.example will be created
      + resource "alicloud_cloud_firewall_instance" "example" {
          + band_width            = 10
          + cfw_log               = false
          + cfw_log_storage       = 1000
          + cfw_service           = false
          + create_time           = (known after apply)
          + end_time              = (known after apply)
          + id                    = (known after apply)
          + ip_number             = 20
          + payment_type          = "Subscription"
          + period                = 6
          + release_time          = (known after apply)
          + renewal_duration_unit = (known after apply)
          + renewal_status        = (known after apply)
          + spec                  = "premium_version"
          + 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.example: Creating...
    alicloud_cloud_firewall_instance.example: Creation complete after 4s [id=vipcloudfw-cn-x0r36mo****]
    
    Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

    コードが実行されると、Cloud Firewallが有効になり、インスタンスIDはvipcloudfw-cn-x0r36mo **** になります。

  2. 結果を表示します。

    • terraform showコマンドを実行し、Cloud Firewallの設定を表示します。

      # alicloud_cloud_firewall_instance.example:
      resource "alicloud_cloud_firewall_instance" "example" {
          band_width            = 10
          cfw_log               = false
          cfw_log_storage       = 1000
          cfw_service           = false
          create_time           = "2023-04-21T01:38:58Z"
          end_time              = "2023-10-21T16:00:00Z"
          id                    = "vipcloudfw-cn-x0r36mo****"
          ip_number             = 20
          payment_type          = "Subscription"
          period                = 6
          renewal_duration_unit = "Month"
          renewal_status        = "ManualRenewal"
          spec                  = "premium_version"
          status                = "Normal"
      }
    • Cloud Firewallコンソールにログインします。 [概要] ページで、[アップグレード] をクリックして、Cloud Firewallの現在の設定を表示します。