Skip to content

feat(lts/transfer): the resource supports new fields #6915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion docs/resources/lts_transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,38 @@ resource "huaweicloud_lts_transfer" "obs_agency" {
}
```

### Create a DMS transfer in JSON format

```hcl
variable "lts_group_id" {}
variable "lts_stream_id" {}
variable "registered_kafka_instance_id" {}
variable "kafka_topic" {}

resource "huaweicloud_lts_transfer" "test" {
log_group_id = var.lts_group_id

log_streams {
log_stream_id = lts_stream_id
}

log_transfer_info {
log_transfer_type = "DMS"
log_transfer_mode = "realTime"
log_storage_format = "JSON"
log_transfer_status = "ENABLE"

log_transfer_detail {
kafka_id = var.registered_kafka_instance_id
kafka_topic = var.kafka_topic
lts_tags = ["hostName", "collectTime"]
stream_tags = ["all"]
struct_fields = ["all"]
}
}
}
```

## Argument Reference

The following arguments are supported:
Expand Down Expand Up @@ -293,10 +325,25 @@ The `log_transfer_detail` block supports:

-> Before creating a DMS transfer task, register your Kafka instance with Kafka ID and Kafka topic first.

* `lts_tags` - (Optional, List) Specifies the list of built-in fields and custom tags to be transferred.
If you want to transfer all built-in and specified fields in the log, you need to set it to **all**.

* `stream_tags` - (Optional, List) Specifies the list of stream tag fields to be transferred.
If you want to transfer all stream tag fields in the log, you need to set it to **all**.

* `struct_fields` - (Optional, List) Specifies the list of structured fields to be transferred.
If you want to transfer all fields in a log in the log, you need to set it to **all**.

-> 1. The `lts_tags`, `stream_tags` and `struct_fields` parameters are valid only for DMS transfer in JSON format.
At least one of them must be set.

* `invalid_field_value` - (Optional, String) Specifies the value of the invalid field fill.

* `delivery_tags` - (Optional, List) The list of tag fields will be delivered when transferring.
This field must contain the following host information: **hostIP**, **hostId**, **hostName**, **pathFile**, and **collectTime**.
The common fields include **logStreamName**, **regionName**, **logGroupName**, and **projectId**, which are optional.
The transfer tag: **streamTag**, which is optional.
The transfer tag: **streamTag**, which is optional.
This parameter is valid only for OBS or DIS transfer in JSON format.

## Attribute Reference

Expand All @@ -306,10 +353,31 @@ In addition to all arguments above, the following attributes are exported:

* `log_group_name` - Log group name.

* `created_at` - The creation time of the log transfer, in RFC3339 format.

## Import

The LTS transfer task can be imported using the `id`, e.g.

```bash
$ terraform import huaweicloud_lts_transfer.test <id>
```

Note that the imported state may not be identical to your resource definition, due to some attributes missing from the
API response.
The missing attributes include: `log_transfer_info.0.log_transfer_detail.0.invalid_field_value`.
It is generally recommended running `terraform plan` after importing the resource.
You can then decide if changes should be applied to the resource, or the resource definition should be updated to
align with the resource. Also you can ignore changes as below.

```hcl
resource "huaweicloud_lts_transfer" "test" {
...

lifecycle {
ignore_changes = [
log_transfer_info.0.log_transfer_detail.0.invalid_field_value
]
}
}
```
10 changes: 10 additions & 0 deletions huaweicloud/services/acceptance/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ var (
HW_LTS_CLUSTER_ID_ANOTHER = os.Getenv("HW_LTS_CLUSTER_ID_ANOTHER")
HW_LTS_CLUSTER_NAME_ANOTHER = os.Getenv("HW_LTS_CLUSTER_NAME_ANOTHER")
HW_LTS_ALARM_ACTION_RULE_NAME = os.Getenv("HW_LTS_ALARM_ACTION_RULE_NAME")
// When registering Kafka using the huaweicloud_lts_register_kafka_instance resource, the interface may time out.
// Therefore, use HW_LTS_REGISTERED_KAFKA_INSTANCE_ID instead.
HW_LTS_REGISTERED_KAFKA_INSTANCE_ID = os.Getenv("HW_LTS_REGISTERED_KAFKA_INSTANCE_ID")

HW_VPCEP_SERVICE_ID = os.Getenv("HW_VPCEP_SERVICE_ID")

Expand Down Expand Up @@ -2241,6 +2244,13 @@ func TestAccPreCheckLtsAlarmActionRuleName(t *testing.T) {
}
}

// lintignore:AT003
func TestAccPreCheckLtsDmsTransfer(t *testing.T) {
if HW_LTS_REGISTERED_KAFKA_INSTANCE_ID == "" {
t.Skip("HW_LTS_REGISTERED_KAFKA_INSTANCE_ID must be set for the acceptance test")
}
}

// lintignore:AT003
func TestAccPreCheckLtsKafkaInstanceIds(t *testing.T) {
if len(strings.Split(HW_LTS_KAFKA_INSTANCE_IDS, ",")) != 2 {
Expand Down
Loading
Loading