Add a member account to Cloud Firewall

更新时间:
复制 MD 格式

Adds a member account to Cloud Firewall for centralized multi-account security management.

For more information, see AddInstanceMembers.

Available since v1.194.0 of the alicloud provider.

Prerequisites

Make sure that you have:

This guide uses Cloud Shell as the runtime environment with Terraform 0.12 and alicloud provider version 1.203.0. The code examples use the required_providers syntax (Terraform 0.13+). If you use Terraform 0.12, specify the provider version in the provider block instead:
provider "alicloud" {
  version = "~> 1.203.0"
}

Example usage

Basic usage

terraform {
  required_providers {
    alicloud = {
      source  = "aliyun/alicloud"
      version = ">= 1.203.0"
    }
  }
}

provider "alicloud" {}

resource "alicloud_cloud_firewall_instance_member" "default" {
  member_desc = "Added memberUid by Terraform"
  member_uid  = 180998553943****
}

Add a member account created by Resource Manager

terraform {
  required_providers {
    alicloud = {
      source  = "aliyun/alicloud"
      version = ">= 1.203.0"
    }
  }
}

provider "alicloud" {}

resource "alicloud_resource_manager_account" "member" {
  display_name = "my-member-account"
}

resource "alicloud_cloud_firewall_instance_member" "default" {
  member_desc = "Added by Terraform"
  member_uid  = alicloud_resource_manager_account.member.id
}

Procedure

  1. Create a file named main.tf in your Terraform working directory and add the configuration from the Example usage section.

  2. Run terraform init to initialize the working directory and download the alicloud provider.

       $ terraform init
  3. Run terraform apply to preview the changes. Review the execution plan, then enter yes to apply. After the resource is created, Terraform returns the member UID as the resource ID (for example, 180998553943****).

       $ terraform apply
  4. Verify the result.

    • Run terraform show to view the member account details:

      $ terraform show
    • Alternatively, log on to the Cloud Firewall console and navigate to System Settings > Multi-account Management to view the member account.

Argument reference

The following arguments are supported:

  • member_uid - (Required, ForceNew) The UID of the member account to add to Cloud Firewall. Changing this forces a new resource to be created.

  • member_desc - (Optional) A description of the member account. For example, "Added memberUid by Terraform".

Attribute reference

The following attributes are exported:

  • id - The member UID of the Cloud Firewall instance member.

  • create_time - The timestamp when the member account was added, in Unix epoch seconds. For example, 1681899524.

  • member_display_name - The display name of the member account. For example, "beaver_qa3".

  • modify_time - The timestamp of the last modification, in Unix epoch seconds.

  • status - The status of the member account. For example, "normal".

Timeouts

The timeouts block specifies timeouts for the following actions:

  • create - (Default 5m) Used when adding a member account to Cloud Firewall.

  • update - (Default 5m) Used when updating the member account description.

  • delete - (Default 1m) Used when removing a member account from Cloud Firewall.

Import

You can import a Cloud Firewall instance member by its member UID.

Using the import block (Terraform v1.5+):

import {
  to = alicloud_cloud_firewall_instance_member.example
  id = "180998553943****"
}

Using terraform import:

$ terraform import alicloud_cloud_firewall_instance_member.example 180998553943****

Related resources