Skip to content

Commit fd4e4a5

Browse files
authored
Merge pull request #33074 from hashicorp/b-kms-tag-propagation
Add `id` logging field for transparent tagging update operations
2 parents a67235d + 2638a0b commit fd4e4a5

File tree

184 files changed

+768
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+768
-0
lines changed

.teamcity/scripts/provider_tests/acceptance_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ TF_ACC=1 go test \
4444
./internal/flex/... \
4545
./internal/framework/... \
4646
./internal/generate/... \
47+
./internal/logging/... \
4748
./internal/maps/... \
4849
./internal/provider/... \
4950
./internal/sdktypes/... \

.teamcity/scripts/provider_tests/unit_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ go test \
1616
./internal/flex/... \
1717
./internal/framework/... \
1818
./internal/generate/... \
19+
./internal/logging/... \
1920
./internal/maps/... \
2021
./internal/provider/... \
2122
./internal/sdktypes/... \

internal/generate/tags/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,12 @@ type TemplateData struct {
208208
FmtPkg bool
209209
HelperSchemaPkg bool
210210
InternalTypesPkg bool
211+
LoggingPkg bool
211212
NamesPkg bool
212213
SkipAWSImp bool
213214
SkipServiceImp bool
214215
SkipTypesImp bool
216+
TfLogPkg bool
215217
TfResourcePkg bool
216218
TimePkg bool
217219

@@ -298,10 +300,12 @@ func main() {
298300
FmtPkg: *updateTags,
299301
HelperSchemaPkg: awsPkg == "autoscaling",
300302
InternalTypesPkg: (*listTags && *listTagsFunc == defaultListTagsFunc) || *serviceTagsMap || *serviceTagsSlice,
303+
LoggingPkg: *updateTags,
301304
NamesPkg: *updateTags && !*skipNamesImp,
302305
SkipAWSImp: *skipAWSImp,
303306
SkipServiceImp: *skipServiceImp,
304307
SkipTypesImp: *skipTypesImp,
308+
TfLogPkg: *updateTags,
305309
TfResourcePkg: (*getTag || *waitForPropagation),
306310
TimePkg: *waitForPropagation,
307311

internal/generate/tags/templates/v1/header_body.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ import (
3131
{{- if .ParentNotFoundErrCode }}
3232
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
3333
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
34+
{{- end }}
35+
{{- if .TfLogPkg }}
36+
"github.com/hashicorp/terraform-plugin-log/tflog"
3437
{{- end }}
3538
{{- if .ConnsPkg }}
3639
"github.com/hashicorp/terraform-provider-aws/internal/conns"
3740
{{- end }}
41+
{{- if .LoggingPkg }}
42+
"github.com/hashicorp/terraform-provider-aws/internal/logging"
43+
{{- end }}
3844
{{- if .TfResourcePkg }}
3945
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
4046
{{- end }}

internal/generate/tags/templates/v1/update_tags_body.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
1010
oldTags := tftags.New(ctx, oldTagsMap)
1111
newTags := tftags.New(ctx, newTagsMap)
1212
{{- end }}
13+
14+
ctx = tflog.SetField(ctx, logging.KeyResourceId, identifier)
15+
1316
{{- if eq (.TagOp) (.UntagOp) }}
17+
1418
removedTags := oldTags.Removed(newTags)
1519
{{- if .UpdateTagsIgnoreSystem }}
1620
removedTags = removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})

internal/generate/tags/templates/v1/wait_tags_propagated_body.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// The identifier is typically the Amazon Resource Name (ARN), although
33
// it may also be a different identifier depending on the service.
44
func {{ .WaitTagsPropagatedFunc }}(ctx context.Context, conn {{ .ClientType }}, id string, tags tftags.KeyValueTags) error {
5+
tflog.Debug(ctx, "Waiting for tag propagation", map[string]any{
6+
"tags": tags,
7+
})
8+
59
checkFunc := func() (bool, error) {
610
output, err := listTags(ctx, conn, id)
711

internal/generate/tags/templates/v2/header_body.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ import (
2828
{{- if .ParentNotFoundErrCode }}
2929
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
3030
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
31+
{{- end }}
32+
{{- if .TfLogPkg }}
33+
"github.com/hashicorp/terraform-plugin-log/tflog"
3134
{{- end }}
3235
{{- if .ConnsPkg }}
3336
"github.com/hashicorp/terraform-provider-aws/internal/conns"
3437
{{- end }}
38+
{{- if .LoggingPkg }}
39+
"github.com/hashicorp/terraform-provider-aws/internal/logging"
40+
{{- end }}
3541
{{- if .TfResourcePkg }}
3642
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
3743
{{- end }}

internal/generate/tags/templates/v2/update_tags_body.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ func {{ .UpdateTagsFunc }}(ctx context.Context, conn {{ .ClientType }}, identifi
1010
oldTags := tftags.New(ctx, oldTagsMap)
1111
newTags := tftags.New(ctx, newTagsMap)
1212
{{- end }}
13+
14+
ctx = tflog.SetField(ctx, logging.KeyResourceId, identifier)
15+
1316
{{- if eq (.TagOp) (.UntagOp) }}
17+
1418
removedTags := oldTags.Removed(newTags)
1519
{{- if .UpdateTagsIgnoreSystem }}
1620
removedTags = removedTags.IgnoreSystem(names.{{ .ProviderNameUpper }})

internal/generate/tags/templates/v2/wait_tags_propagated_body.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// The identifier is typically the Amazon Resource Name (ARN), although
33
// it may also be a different identifier depending on the service.
44
func {{ .WaitTagsPropagatedFunc }}(ctx context.Context, conn {{ .ClientType }}, id string, tags tftags.KeyValueTags) error {
5+
tflog.Debug(ctx, "Waiting for tag propagation", map[string]any{
6+
"tags": tags,
7+
})
8+
59
checkFunc := func() (bool, error) {
610
output, err := listTags(ctx, conn, id)
711

internal/logging/keys.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
package logging
5+
6+
const (
7+
KeyResourceId = "id"
8+
)

internal/service/accessanalyzer/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/acm/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/acmpca/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/amp/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/amplify/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/apigateway/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/apigatewayv2/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/appautoscaling/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/appconfig/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/appflow/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/appintegrations/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/applicationinsights/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/appmesh/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/service/apprunner/tags_gen.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)