alicloud_sddp_data_limit

更新时间:

Provides a Data Security Center Data Limit resource.

For information about Data Security Center Data Limit and how to use it, see What is Data Limit.

-> NOTE: Available since v1.159.0.

Example Usage

Basic Usage


provider "alicloud" {
  region = "cn-hangzhou"
}
variable "name" {
  default = "tf_example"
}
data "alicloud_regions" "default" {
  current = true
}
data "alicloud_db_zones" "default" {
  engine                   = "MySQL"
  engine_version           = "8.0"
  instance_charge_type     = "PostPaid"
  category                 = "Basic"
  db_instance_storage_type = "cloud_essd"
}

data "alicloud_db_instance_classes" "default" {
  zone_id                  = data.alicloud_db_zones.default.zones.0.id
  engine                   = "MySQL"
  engine_version           = "8.0"
  category                 = "Basic"
  db_instance_storage_type = "cloud_essd"
  instance_charge_type     = "PostPaid"
}

resource "alicloud_vpc" "default" {
  vpc_name   = var.name
  cidr_block = "10.4.0.0/16"
}

resource "alicloud_vswitch" "default" {
  vswitch_name = var.name
  cidr_block   = "10.4.0.0/24"
  vpc_id       = alicloud_vpc.default.id
  zone_id      = data.alicloud_db_zones.default.zones.0.id
}

resource "alicloud_security_group" "default" {
  name   = var.name
  vpc_id = alicloud_vpc.default.id
}

resource "alicloud_db_instance" "default" {
  engine                   = "MySQL"
  engine_version           = "8.0"
  instance_type            = data.alicloud_db_instance_classes.default.instance_classes.0.instance_class
  instance_storage         = data.alicloud_db_instance_classes.default.instance_classes.0.storage_range.min
  instance_charge_type     = "Postpaid"
  instance_name            = var.name
  vswitch_id               = alicloud_vswitch.default.id
  monitoring_period        = "60"
  db_instance_storage_type = "cloud_essd"
  security_group_ids       = [alicloud_security_group.default.id]
}

resource "alicloud_rds_account" "default" {
  db_instance_id   = alicloud_db_instance.default.id
  account_name     = var.name
  account_password = "Example1234"
}

resource "alicloud_db_database" "default" {
  instance_id = alicloud_db_instance.default.id
  name        = var.name
}

resource "alicloud_db_account_privilege" "default" {
  instance_id  = alicloud_db_instance.default.id
  account_name = alicloud_rds_account.default.account_name
  privilege    = "ReadWrite"
  db_names     = [alicloud_db_database.default.name]
}

resource "alicloud_sddp_data_limit" "default" {
  audit_status      = 0
  engine_type       = "MySQL"
  parent_id         = join(".", [alicloud_db_account_privilege.default.instance_id, alicloud_db_database.default.name])
  resource_type     = "RDS"
  user_name         = alicloud_db_database.default.name
  password          = alicloud_rds_account.default.account_password
  port              = 3306
  service_region_id = data.alicloud_regions.default.regions.0.id
}

Argument Reference

The following arguments are supported:

  • audit_status - (Optional) Whether to enable the log auditing feature. Valid values: 0, 1.
  • engine_type - (Optional, ForceNew) The type of the database. Valid values: MySQL, SQLServer.
  • lang - (Optional) The lang.
  • log_store_day - (Optional, ForceNew) The retention period of raw logs after you enable the log auditing feature. Unit: day. Valid values: 180, 30, 365, 90. NOTE: Thelog_store_day is valid when the audit_status is 1.
  • parent_id - (Optional, ForceNew) The ID of the data asset.
  • password - (Optional, ForceNew) The password that is used to connect to the database.
  • port - (Optional, ForceNew) The port that is used to connect to the database.
  • resource_type - (Required, ForceNew) The type of the service to which the data asset belongs. Valid values: MaxCompute, OSS, RDS.
  • service_region_id - (Optional, ForceNew) The region ID of the data asset.
  • user_name - (Optional, ForceNew) The name of the service to which the data asset belongs.

Attributes Reference

The following attributes are exported:

  • id - The resource ID in terraform of Data Limit.

Import

Data Security Center Data Limit can be imported using the id, e.g.

$ terraform import alicloud_sddp_data_limit.example <id>