Skip to content
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
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ require (
github.com/hashicorp/go-hclog v1.2.1
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/hcl/v2 v2.13.0
github.com/hashicorp/terraform-plugin-framework v0.9.0
github.com/hashicorp/terraform-plugin-go v0.10.0
github.com/hashicorp/terraform-plugin-log v0.4.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0
github.com/hashicorp/terraform-plugin-framework v0.10.0
github.com/hashicorp/terraform-plugin-go v0.12.0
github.com/hashicorp/terraform-plugin-log v0.6.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0
github.com/jinzhu/inflection v1.0.0
github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24
github.com/mitchellh/cli v1.1.4
Expand Down Expand Up @@ -88,6 +88,6 @@ require (
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
)
25 changes: 10 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/S
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v1.2.1 h1:YQsLlGDJgwhXFpucSPyVbCBviQtjlHv3jLTlp8YmtEw=
github.com/hashicorp/go-hclog v1.2.1/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
Expand All @@ -186,17 +185,14 @@ github.com/hashicorp/terraform-exec v0.17.2 h1:EU7i3Fh7vDUI9nNRdMATCEfnm9axzTnad
github.com/hashicorp/terraform-exec v0.17.2/go.mod h1:tuIbsL2l4MlwwIZx9HPM+LOV9vVyEfBYu2GsO1uH3/8=
github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s=
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
github.com/hashicorp/terraform-plugin-framework v0.9.0 h1:vOKG9+keJv062zGhXFgfOFEuGcfgV6LHciwleFTSek0=
github.com/hashicorp/terraform-plugin-framework v0.9.0/go.mod h1:ActelD2V6yt2m0MwIX4jESGDYJ573rAvZswGjSGm1rY=
github.com/hashicorp/terraform-plugin-go v0.9.1/go.mod h1:ItjVSlQs70otlzcCwlPcU8FRXLdO973oYFRZwAOxy8M=
github.com/hashicorp/terraform-plugin-go v0.10.0 h1:FIQDt/AZDSOXnN+znBnLLZA9aFk4/GwL40rwMLnvuTk=
github.com/hashicorp/terraform-plugin-go v0.10.0/go.mod h1:aphXBG8qtQH0yF1waMRlaw/3G+ZFlR/6Artnvt1QEDE=
github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg=
github.com/hashicorp/terraform-plugin-log v0.4.1 h1:xpbmVhvuU3mgHzLetOmx9pkOL2rmgpu302XxddON6eo=
github.com/hashicorp/terraform-plugin-log v0.4.1/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0 h1:/cdI5di5XA+N80gXzXF4YcHq36DprBskubk6Z8i26ZQ=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.18.0/go.mod h1:L3SHkD/Q8zPVgXviQmpVwy9nKwpXXZscVIpVEnQ/T50=
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co=
github.com/hashicorp/terraform-plugin-framework v0.10.0 h1:LGYcnvNdVaZA1ZHe53BHLVjaaGs7HTiq6+9Js29stL4=
github.com/hashicorp/terraform-plugin-framework v0.10.0/go.mod h1:CK7Opzukfu/2CPJs+HzUdfHrFlp+ZIQeSxjF0x8k464=
github.com/hashicorp/terraform-plugin-go v0.12.0 h1:6wW9mT1dSs0Xq4LR6HXj1heQ5ovr5GxXNJwkErZzpJw=
github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M=
github.com/hashicorp/terraform-plugin-log v0.6.0 h1:/Vq78uSIdUSZ3iqDc9PESKtwt8YqNKN6u+khD+lLjuw=
github.com/hashicorp/terraform-plugin-log v0.6.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0 h1:7gDAcfto/C4Cjtf90SdukQshsxdMxJ/P69QxiF3digI=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.19.0/go.mod h1:/WYikYjhKB7c2j1HmXZhRsAARldRb4M38bLCLOhC3so=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg=
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
Expand Down Expand Up @@ -433,9 +429,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=
google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
17 changes: 9 additions & 8 deletions internal/diag/diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)

Expand All @@ -15,15 +16,15 @@ const (
summaryInvalidLength = "Invalid length"
)

func NewInvalidValueAttributeError(path *tftypes.AttributePath, detail string) diag.Diagnostic {
func NewInvalidValueAttributeError(path path.Path, detail string) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidValue,
detail,
)
}

func NewIncorrectValueTypeAttributeError(path *tftypes.AttributePath, v attr.Value) diag.Diagnostic {
func NewIncorrectValueTypeAttributeError(path path.Path, v attr.Value) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidValueType,
Expand All @@ -38,7 +39,7 @@ func NewIncorrectValueTypeResourceConfigError(t tftypes.Type) diag.Diagnostic {
)
}

func NewUnableToConvertValueTypeAttributeError(path *tftypes.AttributePath, err error) diag.Diagnostic {
func NewUnableToConvertValueTypeAttributeError(path path.Path, err error) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidValueType,
Expand All @@ -53,39 +54,39 @@ func NewUnableToConvertValueTypeResourceConfigError(err error) diag.Diagnostic {
)
}

func NewUnableToObtainValueAttributeError(path *tftypes.AttributePath, err error) diag.Diagnostic {
func NewUnableToObtainValueAttributeError(path path.Path, err error) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryNoTerraformValue,
fmt.Sprintf("unable to obtain Terraform value:\n\n%s", err),
)
}

func NewInvalidLengthBetweenAttributeError(path *tftypes.AttributePath, min, max, len int) diag.Diagnostic {
func NewInvalidLengthBetweenAttributeError(path path.Path, min, max, len int) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidLength,
fmt.Sprintf("expected length to be in the range [%d, %d], got %d", min, max, len),
)
}

func NewInvalidLengthAtLeastAttributeError(path *tftypes.AttributePath, min, len int) diag.Diagnostic {
func NewInvalidLengthAtLeastAttributeError(path path.Path, min, len int) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidLength,
fmt.Sprintf("expected length to be at least %d, got %d", min, len),
)
}

func NewInvalidLengthAtMostAttributeError(path *tftypes.AttributePath, max, len int) diag.Diagnostic {
func NewInvalidLengthAtMostAttributeError(path path.Path, max, len int) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidLength,
fmt.Sprintf("expected length to be at most %d, got %d", max, len),
)
}

func NewInvalidFormatAttributeError(path *tftypes.AttributePath, detail string) diag.Diagnostic {
func NewInvalidFormatAttributeError(path path.Path, detail string) diag.Diagnostic {
return diag.NewAttributeErrorDiagnostic(
path,
summaryInvalidLength,
Expand Down
4 changes: 2 additions & 2 deletions internal/generic/default_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-provider-awscc/internal/tfresource"
)

Expand Down Expand Up @@ -268,7 +268,7 @@ func TestDefaultValue(t *testing.T) {
t.Run(name, func(t *testing.T) {
ctx := context.TODO()
request := tfsdk.ModifyAttributePlanRequest{
AttributePath: tftypes.NewAttributePath().WithAttributeName("test"),
AttributePath: path.Root("test"),
AttributePlan: test.plannedValue,
AttributeState: test.currentValue,
}
Expand Down
12 changes: 7 additions & 5 deletions internal/generic/jsonstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"reflect"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/attr/xattr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)
Expand All @@ -19,7 +21,7 @@ const (
)

var (
_ attr.TypeWithValidate = JSONStringType
_ xattr.TypeWithValidate = JSONStringType
)

func (t jsonStringType) TerraformType(_ context.Context) tftypes.Type {
Expand Down Expand Up @@ -66,12 +68,12 @@ func (t jsonStringType) String() string {
return "JSONStringType"
}

func (t jsonStringType) Validate(ctx context.Context, v tftypes.Value, path *tftypes.AttributePath) diag.Diagnostics {
func (t jsonStringType) Validate(ctx context.Context, v tftypes.Value, p path.Path) diag.Diagnostics {
var diags diag.Diagnostics

if !v.Type().Is(tftypes.String) {
diags.AddAttributeError(
path,
p,
"Duration Type Validation Error",
"An unexpected error was encountered trying to validate an attribute value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+
fmt.Sprintf("Expected String value, received %T with value: %v", v, v),
Expand All @@ -89,7 +91,7 @@ func (t jsonStringType) Validate(ctx context.Context, v tftypes.Value, path *tft

if err != nil {
diags.AddAttributeError(
path,
p,
"Duration Type Validation Error",
"An unexpected error was encountered trying to validate an attribute value. This is always an error in the provider. Please report the following to the provider developer:\n\n"+
fmt.Sprintf("Cannot convert value to String: %s", err),
Expand All @@ -106,7 +108,7 @@ func (t jsonStringType) Validate(ctx context.Context, v tftypes.Value, path *tft

if err != nil {
diags.AddAttributeError(
path,
p,
"JSONString Type Validation Error",
fmt.Sprintf("Value %q cannot be parsed as a JSON string.", v),
)
Expand Down
5 changes: 3 additions & 2 deletions internal/generic/jsonstring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
Expand Down Expand Up @@ -97,7 +98,7 @@ func TestJSONStringTypeValidate(t *testing.T) {
t.Run(name, func(t *testing.T) {
ctx := context.TODO()

attributePath := tftypes.NewAttributePath().WithAttributeName("test")
attributePath := path.Root("test")
diags := JSONStringType.Validate(ctx, test.val, attributePath)

if !diags.HasError() && test.expectError {
Expand Down Expand Up @@ -158,7 +159,7 @@ func TestJSONStringTypeAttributePlanModifier(t *testing.T) {
t.Run(name, func(t *testing.T) {
ctx := context.TODO()
request := tfsdk.ModifyAttributePlanRequest{
AttributePath: tftypes.NewAttributePath().WithAttributeName("test"),
AttributePath: path.Root("test"),
AttributePlan: test.plannedValue,
AttributeState: test.currentValue,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/generic/multiset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-provider-awscc/internal/tfresource"
)

Expand Down Expand Up @@ -118,7 +118,7 @@ func TestMultiset(t *testing.T) {
t.Run(name, func(t *testing.T) {
ctx := context.TODO()
request := tfsdk.ModifyAttributePlanRequest{
AttributePath: tftypes.NewAttributePath().WithAttributeName("test"),
AttributePath: path.Root("test"),
AttributePlan: test.plannedValue,
AttributeState: test.currentValue,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/generic/plural_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (pd *pluralDataSource) list(ctx context.Context, conn *cloudcontrol.Client)

// cfnTypeContext injects the CloudFormation type name into logger contexts.
func (pd *pluralDataSource) cfnTypeContext(ctx context.Context) context.Context {
ctx = tflog.With(ctx, LoggingKeyCFNType, pd.dataSourceType.cfTypeName)
ctx = tflog.SetField(ctx, LoggingKeyCFNType, pd.dataSourceType.cfTypeName)

return ctx
}
Expand Down
20 changes: 10 additions & 10 deletions internal/generic/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
cctypes "github.com/aws/aws-sdk-go-v2/service/cloudcontrol/types"
hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-go/tftypes"
"github.com/hashicorp/terraform-plugin-log/tflog"
tfcloudcontrol "github.com/hashicorp/terraform-provider-awscc/internal/service/cloudcontrol"
"github.com/hashicorp/terraform-provider-awscc/internal/tfresource"
Expand Down Expand Up @@ -118,7 +118,7 @@ func resourceWithSyntheticIDAttribute(v bool) ResourceTypeOptionsFunc {
// the previous calls' values.
func resourceWithWriteOnlyPropertyPaths(v []string) ResourceTypeOptionsFunc {
return func(o *resourceType) error {
writeOnlyAttributePaths := make([]*tftypes.AttributePath, 0)
writeOnlyAttributePaths := make([]*path.Path, 0)

for _, writeOnlyPropertyPath := range v {
writeOnlyAttributePath, err := o.propertyPathToAttributePath(writeOnlyPropertyPath)
Expand Down Expand Up @@ -302,7 +302,7 @@ type resourceType struct {
cfToTfNameMap map[string]string // Map of CloudFormation property name to Terraform attribute name
isImmutableType bool // Resources cannot be updated and must be recreated
syntheticIDAttribute bool // Resource type has a synthetic ID attribute
writeOnlyAttributePaths []*tftypes.AttributePath // Paths to any write-only attributes
writeOnlyAttributePaths []*path.Path // Paths to any write-only attributes
createTimeout time.Duration // Maximum wait time for resource creation
updateTimeout time.Duration // Maximum wait time for resource update
deleteTimeout time.Duration // Maximum wait time for resource deletion
Expand Down Expand Up @@ -341,7 +341,7 @@ func (rt *resourceType) NewResource(ctx context.Context, provider tfsdk.Provider
}

// propertyPathToAttributePath returns the AttributePath for the specified JSON Pointer property path.
func (rt *resourceType) propertyPathToAttributePath(propertyPath string) (*tftypes.AttributePath, error) {
func (rt *resourceType) propertyPathToAttributePath(propertyPath string) (*path.Path, error) {
segments := strings.Split(propertyPath, "/")

if got, expected := len(segments), 3; got < expected {
Expand All @@ -356,7 +356,7 @@ func (rt *resourceType) propertyPathToAttributePath(propertyPath string) (*tftyp
return nil, fmt.Errorf("expected %q for the second property path segment, got: %q", expected, got)
}

attributePath := tftypes.NewAttributePath()
attributePath := path.Empty()

for _, segment := range segments[2:] {
switch segment {
Expand All @@ -368,11 +368,11 @@ func (rt *resourceType) propertyPathToAttributePath(propertyPath string) (*tftyp
if !ok {
return nil, fmt.Errorf("attribute name mapping not found: %s", segment)
}
attributePath = attributePath.WithAttributeName(attributeName)
attributePath = attributePath.AtName(attributeName)
}
}

return attributePath, nil
return &attributePath, nil
}

// Implements tfsdk.Resource.
Expand All @@ -391,7 +391,7 @@ func newGenericResource(provider tfsdk.Provider, resourceType *resourceType) tfs
var (
// Path to the "id" attribute which uniquely (for a specific resource type) identifies the resource.
// This attribute is required for acceptance testing.
idAttributePath = tftypes.NewAttributePath().WithAttributeName("id")
idAttributePath = path.Root("id")
)

func (r *resource) Create(ctx context.Context, request tfsdk.CreateResourceRequest, response *tfsdk.CreateResourceResponse) {
Expand Down Expand Up @@ -551,7 +551,7 @@ func (r *resource) Read(ctx context.Context, request tfsdk.ReadResourceRequest,
// Copy over any write-only values.
// They can only be in the current state.
for _, path := range r.resourceType.writeOnlyAttributePaths {
err = CopyValueAtPath(ctx, &response.State, &request.State, path)
err = CopyValueAtPath(ctx, &response.State, &request.State, *path)

if err != nil {
response.Diagnostics.AddError(
Expand Down Expand Up @@ -816,7 +816,7 @@ func (r *resource) populateUnknownValues(ctx context.Context, id string, state *

// cfnTypeContext injects the CloudFormation type name into logger contexts.
func (r *resource) cfnTypeContext(ctx context.Context) context.Context {
ctx = tflog.With(ctx, LoggingKeyCFNType, r.resourceType.cfTypeName)
ctx = tflog.SetField(ctx, LoggingKeyCFNType, r.resourceType.cfTypeName)

return ctx
}
Expand Down
Loading