Skip to content

Commit 41f7db1

Browse files
authored
Merge pull request #44682 from hashicorp/td-logging-resource-attr
Encapsulates resource attribute logging key
2 parents 79618d9 + 332414a commit 41f7db1

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

internal/logging/keys.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ import (
1313
const (
1414
HTTPKeyRequestBody = "http.request.body"
1515
HTTPKeyResponseBody = "http.response.body"
16-
KeyResourceId = "id"
16+
KeyResourceId = "tf_aws.resource_attribute." + "id"
1717
)
1818

19+
func ResourceAttributeKey(name string) string {
20+
return "tf_aws.resource_attribute." + name
21+
}
22+
1923
// MaskSensitiveValuesByKey masks sensitive values using tflog
2024
func MaskSensitiveValuesByKey(ctx context.Context, keys ...string) context.Context {
2125
l := baselogging.RetrieveLogger(ctx)

internal/service/ec2/vpc_.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/hashicorp/terraform-provider-aws/internal/framework"
3232
fwflex "github.com/hashicorp/terraform-provider-aws/internal/framework/flex"
3333
fwtypes "github.com/hashicorp/terraform-provider-aws/internal/framework/types"
34+
"github.com/hashicorp/terraform-provider-aws/internal/logging"
3435
"github.com/hashicorp/terraform-provider-aws/internal/provider/sdkv2/importer"
3536
"github.com/hashicorp/terraform-provider-aws/internal/retry"
3637
tfslices "github.com/hashicorp/terraform-provider-aws/internal/slices"
@@ -875,7 +876,7 @@ func (l *vpcListResource) List(ctx context.Context, request list.ListRequest, st
875876
}
876877

877878
for _, vpc := range page.Vpcs {
878-
ctx := tflog.SetField(ctx, "tf_aws.resource_attribute.id", aws.ToString(vpc.VpcId))
879+
ctx := tflog.SetField(ctx, logging.ResourceAttributeKey(names.AttrID), aws.ToString(vpc.VpcId))
879880

880881
result := request.NewListResult(ctx)
881882

internal/service/ec2/vpc_subnet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ func (l *subnetListResource) List(ctx context.Context, request list.ListRequest,
823823
}
824824

825825
for _, subnet := range page.Subnets {
826-
ctx := tflog.SetField(ctx, "tf_aws.resource_attribute.id", aws.ToString(subnet.SubnetId))
826+
ctx := tflog.SetField(ctx, logging.ResourceAttributeKey(names.AttrID), aws.ToString(subnet.SubnetId))
827827

828828
result := request.NewListResult(ctx)
829829

0 commit comments

Comments
 (0)