From 37397bca26a028abc13b1459abe7a8eb92cd5591 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Wed, 18 Dec 2024 12:56:45 -0800 Subject: [PATCH 1/3] `go mod tidy` --- tools/tfsdk2fw/go.mod | 16 ++++++++-------- tools/tfsdk2fw/go.sum | 28 ++++++++++++++-------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tools/tfsdk2fw/go.mod b/tools/tfsdk2fw/go.mod index 6f7771666d8..ac1bd7c0202 100644 --- a/tools/tfsdk2fw/go.mod +++ b/tools/tfsdk2fw/go.mod @@ -25,7 +25,7 @@ require ( github.com/aws/aws-sdk-go-v2/config v1.28.7 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.48 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 // indirect - github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.44 // indirect + github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.45 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect @@ -115,9 +115,9 @@ require ( github.com/aws/aws-sdk-go-v2/service/drs v1.30.8 // indirect github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1 // indirect github.com/aws/aws-sdk-go-v2/service/ec2 v1.198.1 // indirect - github.com/aws/aws-sdk-go-v2/service/ecr v1.38.0 // indirect - github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.29.0 // indirect - github.com/aws/aws-sdk-go-v2/service/ecs v1.53.1 // indirect + github.com/aws/aws-sdk-go-v2/service/ecr v1.38.1 // indirect + github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.29.1 // indirect + github.com/aws/aws-sdk-go-v2/service/ecs v1.53.2 // indirect github.com/aws/aws-sdk-go-v2/service/efs v1.34.2 // indirect github.com/aws/aws-sdk-go-v2/service/eks v1.56.0 // indirect github.com/aws/aws-sdk-go-v2/service/elasticache v1.44.2 // indirect @@ -135,7 +135,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/firehose v1.35.3 // indirect github.com/aws/aws-sdk-go-v2/service/fis v1.31.3 // indirect github.com/aws/aws-sdk-go-v2/service/fms v1.38.6 // indirect - github.com/aws/aws-sdk-go-v2/service/fsx v1.51.1 // indirect + github.com/aws/aws-sdk-go-v2/service/fsx v1.51.2 // indirect github.com/aws/aws-sdk-go-v2/service/gamelift v1.38.0 // indirect github.com/aws/aws-sdk-go-v2/service/glacier v1.26.8 // indirect github.com/aws/aws-sdk-go-v2/service/globalaccelerator v1.29.8 // indirect @@ -227,13 +227,13 @@ require ( github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.25.8 // indirect github.com/aws/aws-sdk-go-v2/service/rolesanywhere v1.16.8 // indirect github.com/aws/aws-sdk-go-v2/service/route53 v1.46.4 // indirect - github.com/aws/aws-sdk-go-v2/service/route53domains v1.28.1 // indirect + github.com/aws/aws-sdk-go-v2/service/route53domains v1.28.2 // indirect github.com/aws/aws-sdk-go-v2/service/route53profiles v1.4.8 // indirect github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.25.8 // indirect github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness v1.21.8 // indirect github.com/aws/aws-sdk-go-v2/service/route53resolver v1.34.3 // indirect github.com/aws/aws-sdk-go-v2/service/rum v1.21.8 // indirect - github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1 // indirect + github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0 // indirect github.com/aws/aws-sdk-go-v2/service/s3control v1.52.1 // indirect github.com/aws/aws-sdk-go-v2/service/s3outposts v1.28.8 // indirect github.com/aws/aws-sdk-go-v2/service/s3tables v1.0.1 // indirect @@ -366,7 +366,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect google.golang.org/grpc v1.68.1 // indirect google.golang.org/protobuf v1.35.2 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/hashicorp/terraform-provider-aws => ../.. diff --git a/tools/tfsdk2fw/go.sum b/tools/tfsdk2fw/go.sum index 494f733c72b..600e879700e 100644 --- a/tools/tfsdk2fw/go.sum +++ b/tools/tfsdk2fw/go.sum @@ -33,8 +33,8 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.48 h1:IYdLD1qTJ0zanRavulofmqut4af github.com/aws/aws-sdk-go-v2/credentials v1.17.48/go.mod h1:tOscxHN3CGmuX9idQ3+qbkzrjVIx32lqDSU1/0d/qXs= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22 h1:kqOrpojG71DxJm/KDPO+Z/y1phm1JlC8/iT+5XRmAn8= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.22/go.mod h1:NtSFajXVVL8TA2QNngagVZmUtXciyrHOt7xgz4faS/M= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.44 h1:2zxMLXLedpB4K1ilbJFxtMKsVKaexOqDttOhc0QGm3Q= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.44/go.mod h1:VuLHdqwjSvgftNC7yqPWyGVhEwPmJpeRi07gOgOfHF8= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.45 h1:ZxB8WFVYwolhDZxuZXoesHkl+L9cXLWy0K/G0QkNATc= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.45/go.mod h1:1krrbyoFFDqaNldmltPTP+mK3sAXLHPoaFtISOw2Hkk= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM= @@ -213,12 +213,12 @@ github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1 h1:AnSNs7Ogi0LXHPMDBx4RE7i github.com/aws/aws-sdk-go-v2/service/dynamodb v1.38.1/go.mod h1:J8xqRbx7HIc8ids2P8JbrKx9irONPEYq7Z1FpLDpi3I= github.com/aws/aws-sdk-go-v2/service/ec2 v1.198.1 h1:YbNopxjd9baM83YEEmkaYHi+NuJt0AszeaSLqo0CVr0= github.com/aws/aws-sdk-go-v2/service/ec2 v1.198.1/go.mod h1:mwr3iRm8u1+kkEx4ftDM2Q6Yr0XQFBKrP036ng+k5Lk= -github.com/aws/aws-sdk-go-v2/service/ecr v1.38.0 h1:+1IqznlfeMCgFWoWAuwRqykVc6gGoUUQFGXai+77KWs= -github.com/aws/aws-sdk-go-v2/service/ecr v1.38.0/go.mod h1:NqKnlZvLl4Tp2UH/GEc/nhbjmPQhwOXmLp2eldiszLM= -github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.29.0 h1:4s8fI+O6gumMp1fU8Lvi0TM9al3eP1JCj6c0o9olqig= -github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.29.0/go.mod h1:aHMIyHh+6N2w3CY24J9JoV5ADnGuMZ7dnOJTzO0Txik= -github.com/aws/aws-sdk-go-v2/service/ecs v1.53.1 h1:sAT2jzHkds1cv7VvNpzFfCw2w3zAkh306x3MTLPjuoA= -github.com/aws/aws-sdk-go-v2/service/ecs v1.53.1/go.mod h1:YpTRClSDOPvN2e3kiIrYOx1sI+YKTZVmlMiNO2AwYhE= +github.com/aws/aws-sdk-go-v2/service/ecr v1.38.1 h1:pCI3RIJnZEUs0evNm+pdDzvAp+YwpabUyQTPPvxO8oY= +github.com/aws/aws-sdk-go-v2/service/ecr v1.38.1/go.mod h1:NqKnlZvLl4Tp2UH/GEc/nhbjmPQhwOXmLp2eldiszLM= +github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.29.1 h1:pD3CFGTKwsB8TFjTohMWz0Qb1PuYpI78vYU8s5yhLx8= +github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.29.1/go.mod h1:aHMIyHh+6N2w3CY24J9JoV5ADnGuMZ7dnOJTzO0Txik= +github.com/aws/aws-sdk-go-v2/service/ecs v1.53.2 h1:o/FdG76sTAoC8h20j6bSBE6MPJYOZhNIh0nJ8Q8druY= +github.com/aws/aws-sdk-go-v2/service/ecs v1.53.2/go.mod h1:YpTRClSDOPvN2e3kiIrYOx1sI+YKTZVmlMiNO2AwYhE= github.com/aws/aws-sdk-go-v2/service/efs v1.34.2 h1:gV7yKX8euN6W9vXiPutShochfx5ren706E9D0qsoOjo= github.com/aws/aws-sdk-go-v2/service/efs v1.34.2/go.mod h1:SB5IpCGoPDDTpf7wMLVtq5MRsad+vqIMONmJf/l4nqY= github.com/aws/aws-sdk-go-v2/service/eks v1.56.0 h1:x31cGGE/t/QkrHVh5m2uWvYwDiaDXpj88nh6OdnI5r0= @@ -253,8 +253,8 @@ github.com/aws/aws-sdk-go-v2/service/fis v1.31.3 h1:Pyde+VIhO71j5j+BXiwA2civiljv github.com/aws/aws-sdk-go-v2/service/fis v1.31.3/go.mod h1:lMzi+Vbnzlq6fPfIvHPWoX2LHKM2S2EOn5z6Vx71nmw= github.com/aws/aws-sdk-go-v2/service/fms v1.38.6 h1:AC3x00ZKA10zqPJuq6djqZ4SQJOgPSNJWsMYlmoHP4E= github.com/aws/aws-sdk-go-v2/service/fms v1.38.6/go.mod h1:B3Vak6cFQfuW0ngCa07XogB2G4UNbPsx2RX8i09HYRI= -github.com/aws/aws-sdk-go-v2/service/fsx v1.51.1 h1:+aV/de4zHh5njmTWH9+OtbJ78KHxcdg8YLYjtqQLCaU= -github.com/aws/aws-sdk-go-v2/service/fsx v1.51.1/go.mod h1:cNaIag1SJLzfaYSGY0TY6blDFVpQjRqHfb3NhANZmTo= +github.com/aws/aws-sdk-go-v2/service/fsx v1.51.2 h1:ebMa63iPLHJ0dQgNTu5hJcYtmvr97SgJBMgdJ4Czqzc= +github.com/aws/aws-sdk-go-v2/service/fsx v1.51.2/go.mod h1:cNaIag1SJLzfaYSGY0TY6blDFVpQjRqHfb3NhANZmTo= github.com/aws/aws-sdk-go-v2/service/gamelift v1.38.0 h1:KNBSQcM3wuDev57F/ORYpX51mOvPjyFu3SSsS2CzHo4= github.com/aws/aws-sdk-go-v2/service/gamelift v1.38.0/go.mod h1:vrO+dsUPRzqUFiNr5T/9fm2bCZDcQZ8q46anRzviwxk= github.com/aws/aws-sdk-go-v2/service/glacier v1.26.8 h1:6J1jxl2VB+BNVlI8z/XoJVf5oCjh/Cjz3T6lqU3V8EE= @@ -437,8 +437,8 @@ github.com/aws/aws-sdk-go-v2/service/rolesanywhere v1.16.8 h1:UZGvejgPVw0Qhwt3Ku github.com/aws/aws-sdk-go-v2/service/rolesanywhere v1.16.8/go.mod h1:xgh2UyLblHo40RL4po9e7D1iHfAsA85SxtbfdlDN7pk= github.com/aws/aws-sdk-go-v2/service/route53 v1.46.4 h1:0jMtawybbfpFEIMy4wvfyW2Z4YLr7mnuzT0fhR67Nrc= github.com/aws/aws-sdk-go-v2/service/route53 v1.46.4/go.mod h1:xlMODgumb0Pp8bzfpojqelDrf8SL9rb5ovwmwKJl+oU= -github.com/aws/aws-sdk-go-v2/service/route53domains v1.28.1 h1:JQtBxTNftIOozmHvZaD2ZvtS4oJ9zP8W7T/Toy7fDXg= -github.com/aws/aws-sdk-go-v2/service/route53domains v1.28.1/go.mod h1:kbxY8XfDPZYpcBqQtezB8r1DqZWgCydOSmgoKcTjvf4= +github.com/aws/aws-sdk-go-v2/service/route53domains v1.28.2 h1:IH+UWySP8buYbojqBKwOGOZN6zpAc4sd8gTDLEJYl74= +github.com/aws/aws-sdk-go-v2/service/route53domains v1.28.2/go.mod h1:kbxY8XfDPZYpcBqQtezB8r1DqZWgCydOSmgoKcTjvf4= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.4.8 h1:U1hxHsKRnTh4tI8Ntv0MOsaOH+MdClktUjz0UDcvcPc= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.4.8/go.mod h1:AitHbOsoMtRWbTE62FvieGF8JMaKcWIMsWV+MgOYn+U= github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig v1.25.8 h1:gMqOTyw8VBzA6O/4jdZ7VyZd9+U4DtO/YfOayBOpwsw= @@ -449,8 +449,8 @@ github.com/aws/aws-sdk-go-v2/service/route53resolver v1.34.3 h1:80FDkostVF+fDsRL github.com/aws/aws-sdk-go-v2/service/route53resolver v1.34.3/go.mod h1:vYD7xWxRn4FA2LL0zRgiP4GQZPev0VIuKWOYPdU7LEU= github.com/aws/aws-sdk-go-v2/service/rum v1.21.8 h1:PsjsKI4htYgVNS7SkrvDamC1pudlKdebfKKfT+B+p0k= github.com/aws/aws-sdk-go-v2/service/rum v1.21.8/go.mod h1:2k7Pf5TV51+bdYg994/m6Pg9pDEU3/75ljg0twzfeqc= -github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1 h1:aOVVZJgWbaH+EJYPvEgkNhCEbXXvH7+oML36oaPK3zE= -github.com/aws/aws-sdk-go-v2/service/s3 v1.71.1/go.mod h1:r+xl5yzMk9083rMR+sJ5TYj9Tihvf/l1oxzZXDgGj2Q= +github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0 h1:SAfh4pNx5LuTafKKWR02Y+hL3A+3TX8cTKG1OIAJaBk= +github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0/go.mod h1:r+xl5yzMk9083rMR+sJ5TYj9Tihvf/l1oxzZXDgGj2Q= github.com/aws/aws-sdk-go-v2/service/s3control v1.52.1 h1:xxGbXbGtO/VMz2JqB1UwEDlSchryUss0KmQJSZ0oTUE= github.com/aws/aws-sdk-go-v2/service/s3control v1.52.1/go.mod h1:6BuUa52of67a+ri/poTH82XiL+rTGQWUPZCmf2cfVHI= github.com/aws/aws-sdk-go-v2/service/s3outposts v1.28.8 h1:47G52E232ytagHeaPcTIxd8GaVstyT4fKS9CrVRWbXM= From af78be47a69062493e08495e33c01cc42afaf940 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Wed, 18 Dec 2024 13:32:33 -0800 Subject: [PATCH 2/3] Migrates `id` attribute to `framework.IDAttribute()` --- tools/tfsdk2fw/main.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/tfsdk2fw/main.go b/tools/tfsdk2fw/main.go index b9c99be197a..26bef77dcc9 100644 --- a/tools/tfsdk2fw/main.go +++ b/tools/tfsdk2fw/main.go @@ -290,10 +290,12 @@ func (e *emitter) emitAttributesAndBlocks(path []string, schema map[string]*sche fprintf(e.StructWriter, "%s ", naming.ToCamelCase(name)) } - err := e.emitAttributeProperty(append(path, name), property) - - if err != nil { - return err + if name == "id" && isTopLevelAttribute { + fprintf(e.SchemaWriter, "framework.IDAttribute()") + } else { + if err := e.emitAttributeProperty(append(path, name), property); err != nil { + return err + } } if isTopLevelAttribute { @@ -393,10 +395,6 @@ func (e *emitter) emitAttributeProperty(path []string, property *schema.Schema) fprintf(e.StructWriter, "fwtypes.ARN") } } else { - if isTopLevelAttribute && attributeName == "id" { - fprintf(e.SchemaWriter, "// TODO framework.IDAttribute()\n") - } - fprintf(e.SchemaWriter, "schema.StringAttribute{\n") if isTopLevelAttribute { @@ -552,11 +550,6 @@ func (e *emitter) emitAttributeProperty(path []string, property *schema.Schema) fprintf(e.SchemaWriter, "},\n") } - if attributeName == "id" && isTopLevelAttribute && !e.IsDataSource { - planModifiers = append(planModifiers, fmt.Sprintf("%s.UseStateForUnknown()", fwPlanModifierPackage)) - e.FrameworkPlanModifierPackages = append(e.FrameworkPlanModifierPackages, fwPlanModifierPackage) - } - if property.ForceNew { planModifiers = append(planModifiers, fmt.Sprintf("%s.RequiresReplace()", fwPlanModifierPackage)) e.FrameworkPlanModifierPackages = append(e.FrameworkPlanModifierPackages, fwPlanModifierPackage) From b404c097b5da02e957ae32c1500e97f97ec4cc4f Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Wed, 18 Dec 2024 13:32:59 -0800 Subject: [PATCH 3/3] Adds instructions for which default `IDAttribute` variant to use --- tools/tfsdk2fw/main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/tfsdk2fw/main.go b/tools/tfsdk2fw/main.go index 26bef77dcc9..2ae9d65f737 100644 --- a/tools/tfsdk2fw/main.go +++ b/tools/tfsdk2fw/main.go @@ -284,6 +284,15 @@ func (e *emitter) emitAttributesAndBlocks(path []string, schema map[string]*sche emittedFieldName = true } + if name == "id" && isTopLevelAttribute { + fprintf(e.SchemaWriter, `// If the AWS API structs have an "...Id" field, use framework.IDAttribute()`+"\n") + if e.IsDataSource { + fprintf(e.SchemaWriter, `// Otherwise, use framework.IDAttributeDeprecatedNoReplacement()`+"\n") + } else { + fprintf(e.SchemaWriter, `// Otherwise, if the "id" attribute is set to a single attribute of the resource, use framework.IDAttributeDeprecatedWithAlternate()`+"\n") + fprintf(e.SchemaWriter, `// If the "id" attribute is composed from multiple attributes of the resource, use framework.IDAttributeDeprecatedNoReplacement()`+"\n") + } + } fprintf(e.SchemaWriter, "%q:", name) if isTopLevelAttribute {