Skip to content

Commit

Permalink
fix(vpc): [120743758] tencentcloud_vpc_flow_logsupport modifying `t…
Browse files Browse the repository at this point in the history
…ags` (#2963)

* add

* add
  • Loading branch information
SevenEarth authored Nov 22, 2024
1 parent 5f3a2c2 commit 9eb079e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .changelog/2963.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_vpc_flow_log: support modifying `tags`
```
34 changes: 16 additions & 18 deletions tencentcloud/services/fl/resource_tc_vpc_flow_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,33 +325,31 @@ func resourceTencentCloudVpcFlowLogUpdate(d *schema.ResourceData, meta interface
}
}

request.FlowLogId = &flowLogId
request.VpcId = &vpcId

if d.HasChange("flow_log_name") {
if d.HasChange("flow_log_name") || d.HasChange("flow_log_description") {
if v, ok := d.GetOk("flow_log_name"); ok {
request.FlowLogName = helper.String(v.(string))
}
}

if d.HasChange("flow_log_description") {
if v, ok := d.GetOk("flow_log_description"); ok {
request.FlowLogDescription = helper.String(v.(string))
}
}

err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyFlowLogAttribute(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
request.FlowLogId = &flowLogId
request.VpcId = &vpcId
err = resource.Retry(tccommon.WriteRetryTimeout, func() *resource.RetryError {
result, e := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseVpcClient().ModifyFlowLogAttribute(request)
if e != nil {
return tccommon.RetryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
}
return nil
})

if err != nil {
log.Printf("[CRITAL]%s update vpc flowLog failed, reason:%+v", logId, err)
return err
}
return nil
})
if err != nil {
log.Printf("[CRITAL]%s update vpc flowLog failed, reason:%+v", logId, err)
return err
}

if d.HasChange("tags") {
Expand Down
26 changes: 13 additions & 13 deletions tencentcloud/services/fl/resource_tc_vpc_flow_log.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ data "tencentcloud_instance_types" "instance_types" {
}
resource "tencentcloud_cls_logset" "logset" {
logset_name = "delogsetmo"
tags = {
"test" = "test"
logset_name = "logset"
tags = {
createBy = "Terraform"
}
}
Expand All @@ -44,34 +44,34 @@ resource "tencentcloud_cls_topic" "topic" {
partition_count = 1
period = 10
storage_type = "hot"
tags = {
"test" = "test",
tags = {
createBy = "Terraform"
}
}
resource "tencentcloud_vpc" "vpc" {
name = "vpc-flow-log-vpc"
name = "vpc"
cidr_block = "10.0.0.0/16"
}
resource "tencentcloud_subnet" "subnet" {
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
name = "vpc-flow-log-subnet"
name = "subnet"
vpc_id = tencentcloud_vpc.vpc.id
cidr_block = "10.0.0.0/16"
is_multicast = false
}
resource "tencentcloud_eni" "example" {
name = "vpc-flow-log-eni"
name = "tf-example"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
description = "eni desc"
ipv4_count = 1
}
resource "tencentcloud_instance" "example" {
instance_name = "ci-test-eni-attach"
instance_name = "tf-example"
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
image_id = data.tencentcloud_images.image.images.0.image_id
instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type
Expand All @@ -88,16 +88,16 @@ resource "tencentcloud_eni_attachment" "example" {
}
resource "tencentcloud_vpc_flow_log" "example" {
flow_log_name = "tf-example-vpc-flow-log"
flow_log_name = "tf-example"
resource_type = "NETWORKINTERFACE"
resource_id = tencentcloud_eni_attachment.example.eni_id
traffic_type = "ACCEPT"
vpc_id = tencentcloud_vpc.vpc.id
flow_log_description = "this is a testing flow log"
cloud_log_id = tencentcloud_cls_topic.topic.id
storage_type = "cls"
tags = {
"testKey" = "testValue"
tags = {
createBy = "Terraform"
}
}
```
Expand All @@ -107,5 +107,5 @@ Import
vpc flow_log can be imported using the flow log Id combine vpc Id, e.g.

```
$ terraform import tencentcloud_vpc_flow_log.flow_log flow_log_id fl-xxxx1234#vpc-yyyy5678
$ terraform import tencentcloud_vpc_flow_log.example fl-7k59x22l#vpc-n6qjlen5
```
20 changes: 10 additions & 10 deletions website/docs/r/vpc_flow_log.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ data "tencentcloud_instance_types" "instance_types" {
}
resource "tencentcloud_cls_logset" "logset" {
logset_name = "delogsetmo"
logset_name = "logset"
tags = {
"test" = "test"
createBy = "Terraform"
}
}
Expand All @@ -56,33 +56,33 @@ resource "tencentcloud_cls_topic" "topic" {
period = 10
storage_type = "hot"
tags = {
"test" = "test",
createBy = "Terraform"
}
}
resource "tencentcloud_vpc" "vpc" {
name = "vpc-flow-log-vpc"
name = "vpc"
cidr_block = "10.0.0.0/16"
}
resource "tencentcloud_subnet" "subnet" {
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
name = "vpc-flow-log-subnet"
name = "subnet"
vpc_id = tencentcloud_vpc.vpc.id
cidr_block = "10.0.0.0/16"
is_multicast = false
}
resource "tencentcloud_eni" "example" {
name = "vpc-flow-log-eni"
name = "tf-example"
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
description = "eni desc"
ipv4_count = 1
}
resource "tencentcloud_instance" "example" {
instance_name = "ci-test-eni-attach"
instance_name = "tf-example"
availability_zone = data.tencentcloud_availability_zones.zones.zones.0.name
image_id = data.tencentcloud_images.image.images.0.image_id
instance_type = data.tencentcloud_instance_types.instance_types.instance_types.0.instance_type
Expand All @@ -99,7 +99,7 @@ resource "tencentcloud_eni_attachment" "example" {
}
resource "tencentcloud_vpc_flow_log" "example" {
flow_log_name = "tf-example-vpc-flow-log"
flow_log_name = "tf-example"
resource_type = "NETWORKINTERFACE"
resource_id = tencentcloud_eni_attachment.example.eni_id
traffic_type = "ACCEPT"
Expand All @@ -108,7 +108,7 @@ resource "tencentcloud_vpc_flow_log" "example" {
cloud_log_id = tencentcloud_cls_topic.topic.id
storage_type = "cls"
tags = {
"testKey" = "testValue"
createBy = "Terraform"
}
}
```
Expand Down Expand Up @@ -147,6 +147,6 @@ In addition to all arguments above, the following attributes are exported:
vpc flow_log can be imported using the flow log Id combine vpc Id, e.g.

```
$ terraform import tencentcloud_vpc_flow_log.flow_log flow_log_id fl-xxxx1234#vpc-yyyy5678
$ terraform import tencentcloud_vpc_flow_log.example fl-7k59x22l#vpc-n6qjlen5
```

0 comments on commit 9eb079e

Please sign in to comment.